aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-01-06 03:20:40 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:07 -0500
commit1345b1d8adbdeceb1c871d9a4af5e2a700b341c6 (patch)
tree0da1db7d273752ad5281db415e9245f3f3a63383 /drivers/md/raid1.c
parent7dd5d34c6c2da04e8cd0732e08b33cd3359e4bae (diff)
[PATCH] md: define and use safe_put_page for md
md sometimes call put_page on NULL pointers (treating it like kfree). This is not safe, so define and use a 'safe_put_page' which checks for NULL. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 39c10a65683d..feea4eeca1d9 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -136,7 +136,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
136out_free_pages: 136out_free_pages:
137 for (i=0; i < RESYNC_PAGES ; i++) 137 for (i=0; i < RESYNC_PAGES ; i++)
138 for (j=0 ; j < pi->raid_disks; j++) 138 for (j=0 ; j < pi->raid_disks; j++)
139 put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); 139 safe_put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page);
140 j = -1; 140 j = -1;
141out_free_bio: 141out_free_bio:
142 while ( ++j < pi->raid_disks ) 142 while ( ++j < pi->raid_disks )
@@ -156,7 +156,7 @@ static void r1buf_pool_free(void *__r1_bio, void *data)
156 if (j == 0 || 156 if (j == 0 ||
157 r1bio->bios[j]->bi_io_vec[i].bv_page != 157 r1bio->bios[j]->bi_io_vec[i].bv_page !=
158 r1bio->bios[0]->bi_io_vec[i].bv_page) 158 r1bio->bios[0]->bi_io_vec[i].bv_page)
159 put_page(r1bio->bios[j]->bi_io_vec[i].bv_page); 159 safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page);
160 } 160 }
161 for (i=0 ; i < pi->raid_disks; i++) 161 for (i=0 ; i < pi->raid_disks; i++)
162 bio_put(r1bio->bios[i]); 162 bio_put(r1bio->bios[i]);
@@ -381,7 +381,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
381 /* free extra copy of the data pages */ 381 /* free extra copy of the data pages */
382 int i = bio->bi_vcnt; 382 int i = bio->bi_vcnt;
383 while (i--) 383 while (i--)
384 put_page(bio->bi_io_vec[i].bv_page); 384 safe_put_page(bio->bi_io_vec[i].bv_page);
385 } 385 }
386 /* clear the bitmap if all writes complete successfully */ 386 /* clear the bitmap if all writes complete successfully */
387 bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector, 387 bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector,
@@ -1907,7 +1907,7 @@ out_free_conf:
1907 if (conf->r1bio_pool) 1907 if (conf->r1bio_pool)
1908 mempool_destroy(conf->r1bio_pool); 1908 mempool_destroy(conf->r1bio_pool);
1909 kfree(conf->mirrors); 1909 kfree(conf->mirrors);
1910 put_page(conf->tmppage); 1910 safe_put_page(conf->tmppage);
1911 kfree(conf->poolinfo); 1911 kfree(conf->poolinfo);
1912 kfree(conf); 1912 kfree(conf);
1913 mddev->private = NULL; 1913 mddev->private = NULL;