Skip to contentSkip to conversation

raid5: fix possible oops in add_stripe_bio when enable pr_debug

PATCH In review Jianpeng Ma 1 participant 1 message Sep 22, 2012 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 raid5: fix possible oops in add_stripe_bio when enable pr_debug

In function add_stripe_bio:

Quoted 8 lines
Quoted 8 lines

.....

		bip = &sh->dev[dd_idx].toread;

......
spin_unlock_irq(&sh->stripe_lock);

	pr_debug("added bi b#%llu to stripe s#%llu, disk %d.\n",
		(unsigned long long)(*bip)->bi_sector,
		(unsigned long long)sh->sector, dd_idx);

After spin_unlock_irq, this thread scheded and toread may become null. So it will be oops.

---
 drivers/md/raid5.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid5.c +2 -1
index dd73209..a56aa5b 100644
@@ -2360,6 +2360,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
 	struct bio **bip;
 	struct r5conf *conf = sh->raid_conf;
 	int firstwrite=0;
+	sector_t sector = bi->bi_sector;
 
 	pr_debug("adding bi b#%llu to stripe s#%llu\n",
 		(unsigned long long)bi->bi_sector,
@@ -2410,7 +2411,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
 	spin_unlock_irq(&sh->stripe_lock);
 
 	pr_debug("added bi b#%llu to stripe s#%llu, disk %d.\n",
-		(unsigned long long)(*bip)->bi_sector,
+		(unsigned long long)sector,
 		(unsigned long long)sh->sector, dd_idx);
 
 	if (conf->mddev->bitmap && firstwrite) {
Signature · 1 line
1.7.9.5