From: NeilBrown <neilb@suse.de>
To: Dan Carpenter <error27@gmail.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [smatch stuff] md/raid5: potential null deref in debug code
Date: Tue, 28 Jun 2011 16:42:25 +1000 [thread overview]
Message-ID: <20110628164225.22107a37@notabene.brown> (raw)
In-Reply-To: <20110624181235.GQ14591@shale.localdomain>
On Fri, 24 Jun 2011 21:12:36 +0300 Dan Carpenter <error27@gmail.com> wrote:
> Hi Neil,
>
> In d1b053e4de0ac33 "md/raid5: Protect some more code with
> ->device_lock." we moved some debug code around and it upsets my
> static checker. Could you take a look?
>
> drivers/md/raid5.c +2183 add_stripe_bio(47)
> error: potential null derefence 'bi'.
>
> 2168 if (forwrite) {
> 2169 /* check if page is covered */
> 2170 sector_t sector = sh->dev[dd_idx].sector;
> 2171 for (bi=sh->dev[dd_idx].towrite;
> 2172 sector < sh->dev[dd_idx].sector + STRIPE_SECTORS &&
> 2173 bi && bi->bi_sector <= sector;
> ^^
> It looks like "bi" can be NULL at the end of this for loop.
>
>
> 2174 bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) {
> 2175 if (bi->bi_sector + (bi->bi_size>>9) >= sector)
> 2176 sector = bi->bi_sector + (bi->bi_size>>9);
> 2177 }
> 2178 if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS)
> 2179 set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags);
> 2180 }
> 2181 spin_unlock_irq(&conf->device_lock);
> 2182
> 2183 pr_debug("added bi b#%llu to stripe s#%llu, disk %d.\n",
> 2184 (unsigned long long)bi->bi_sector,
> ^^^^^^^^^^^^^
> We dereference it here.
>
> 2185 (unsigned long long)sh->sector, dd_idx);
>
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks Dan,
as it happens I received a patch just the day before from Namhyung Kim which
fixes that bug - so all fixed now.
Thanks,
NeilBrown
prev parent reply other threads:[~2011-06-28 6:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 18:12 [smatch stuff] md/raid5: potential null deref in debug code Dan Carpenter
2011-06-28 6:42 ` NeilBrown [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=20110628164225.22107a37@notabene.brown \
--to=neilb@suse.de \
--cc=error27@gmail.com \
--cc=linux-raid@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).