aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/raid56.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-07-22 02:55:15 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-01 08:04:26 -0400
commit3dc0e818afa25a605091b6a16c2c4e5698c0a9c2 (patch)
tree148c006bde1ff423c9623e33ccd1d45ae16688fd /fs/btrfs/raid56.c
parent2112ac800d43e795323bc18558e43fd3641da4ed (diff)
btrfs/raid56: fix and cleanup some error paths
The alloc_rbio() frees "raid_map" and "bbio" on error, so there is a potential double free bug in raid56_parity_write(). The raid56_parity_write() and raid56_parity_recover() functions should still free "raid_map" and "bbio" on error if other errors occur though, so I have added some more calls to kfree(). Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/raid56.c')
-rw-r--r--fs/btrfs/raid56.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 0525e1389f5b..0db856ceecc4 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1687,11 +1687,8 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio,
1687 struct blk_plug_cb *cb; 1687 struct blk_plug_cb *cb;
1688 1688
1689 rbio = alloc_rbio(root, bbio, raid_map, stripe_len); 1689 rbio = alloc_rbio(root, bbio, raid_map, stripe_len);
1690 if (IS_ERR(rbio)) { 1690 if (IS_ERR(rbio))
1691 kfree(raid_map);
1692 kfree(bbio);
1693 return PTR_ERR(rbio); 1691 return PTR_ERR(rbio);
1694 }
1695 bio_list_add(&rbio->bio_list, bio); 1692 bio_list_add(&rbio->bio_list, bio);
1696 rbio->bio_list_bytes = bio->bi_size; 1693 rbio->bio_list_bytes = bio->bi_size;
1697 1694
@@ -2041,9 +2038,8 @@ int raid56_parity_recover(struct btrfs_root *root, struct bio *bio,
2041 int ret; 2038 int ret;
2042 2039
2043 rbio = alloc_rbio(root, bbio, raid_map, stripe_len); 2040 rbio = alloc_rbio(root, bbio, raid_map, stripe_len);
2044 if (IS_ERR(rbio)) { 2041 if (IS_ERR(rbio))
2045 return PTR_ERR(rbio); 2042 return PTR_ERR(rbio);
2046 }
2047 2043
2048 rbio->read_rebuild = 1; 2044 rbio->read_rebuild = 1;
2049 bio_list_add(&rbio->bio_list, bio); 2045 bio_list_add(&rbio->bio_list, bio);
@@ -2052,6 +2048,8 @@ int raid56_parity_recover(struct btrfs_root *root, struct bio *bio,
2052 rbio->faila = find_logical_bio_stripe(rbio, bio); 2048 rbio->faila = find_logical_bio_stripe(rbio, bio);
2053 if (rbio->faila == -1) { 2049 if (rbio->faila == -1) {
2054 BUG(); 2050 BUG();
2051 kfree(raid_map);
2052 kfree(bbio);
2055 kfree(rbio); 2053 kfree(rbio);
2056 return -EIO; 2054 return -EIO;
2057 } 2055 }