Skip to contentSkip to conversation

Subject:[PATCH 002:013]: raid0: find_zone to return NULL

PATCH raz ben yehuda 1 participant 1 message Jun 16, 2009 MD RAID

lore
Share & tools
lore
#0 lore raw

Have the caller decide whether to report BUG()
when zone is incorrect

 raid0.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

---

drivers/md/raid0.c +3 -1
index 851e631..8870acc 100644
@@ -377,7 +377,7 @@ static struct strip_zone *find_zone(struct raid0_private_data *conf,
 				*sectorp = sector - z[i-1].zone_end;
 			return z + i;
 		}
-	BUG();
+	return NULL;
 }
 
 /*
@@ -481,6 +481,8 @@ static int raid0_make_request(struct request_queue *q, struct bio *bio)
 
 	sector_offset = bio->bi_sector;
 	zone =  find_zone(mddev->private, &sector_offset);
+	if (!zone)
+		BUG();
 	tmp_dev = map_sector(mddev, zone, bio->bi_sector,
 			     &sector_offset);
 	bio->bi_bdev = tmp_dev->bdev;