public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>, linux-mtd@lists.infradead.org
Subject: Re: question about fs/ubifs/orphan.c
Date: Mon, 09 Jul 2012 09:47:22 +0300	[thread overview]
Message-ID: <4FFA7E7A.7030708@intel.com> (raw)
In-Reply-To: <1341751213.2104.7.camel@koala>

On 08/07/12 15:40, Artem Bityutskiy wrote:
> On Sun, 2012-07-08 at 11:21 +0200, Julia Lawall wrote:
>> The function ubifs_orphan_start_commit contains the code:
>>
>>          list_for_each_entry(orphan, &c->orph_new, new_list) {
>>                  ubifs_assert(orphan->new);
>>                  orphan->new = 0;
>>                  *last = orphan;
>>                  last = &orphan->cnext;
>>          }
>>          *last = orphan->cnext;
>>
>> After list_for_each_entry, orphan is just an address at an offset from the 
>> list head, not a pointer to a real structure.  So it does not seem correct 
>> to access its cnext field.
> 
> Looks like you've spotted a but - we write some irrelevant address to an
> area within the 'struct ubifs_info'.
> 
> I think what the code meant to do is to write NULL there:
> 
> - *last = orphan->cnext;
> + *last = NULL;
> 
> I wonder if this could be a reason for some of strange bugs we have seen
> reports for.

Perhaps not because in that case c->cmt_orphans is zero so the cnext list
is never dereferenced.

> 
> Well-spotted Julia, thanks! How did you do this - writing another cocci
> script for the kernel?
> 

      parent reply	other threads:[~2012-07-09  6:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-08  9:21 question about fs/ubifs/orphan.c Julia Lawall
2012-07-08  9:22 ` Julia Lawall
2012-07-09  6:46   ` Adrian Hunter
2012-07-09  7:21     ` Julia Lawall
2012-07-08 12:40 ` Artem Bityutskiy
2012-07-08 13:06   ` Julia Lawall
2012-07-09  6:47   ` Adrian Hunter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FFA7E7A.7030708@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=dedekind1@gmail.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox