From: Dan Carpenter <error27@gmail.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org
Subject: [smatch stuff] md/raid5: potential null deref in debug code
Date: Fri, 24 Jun 2011 21:12:36 +0300 [thread overview]
Message-ID: <20110624181235.GQ14591@shale.localdomain> (raw)
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
next reply other threads:[~2011-06-24 18:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 18:12 Dan Carpenter [this message]
2011-06-28 6:42 ` [smatch stuff] md/raid5: potential null deref in debug code NeilBrown
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=20110624181235.GQ14591@shale.localdomain \
--to=error27@gmail.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/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