bdev: fix ->bd_part_count leak
PATCH 1/1 bdev: fix ->bd_part_count leak
Don't leak a ->bd_part_count when the partition open fails with -ENXIO.
Signed-off-by Peter Zijlstra <[email protected]>
--- fs/block_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/block_dev.c +2 -1
@@ -907,6 +907,7 @@ EXPORT_SYMBOL(bd_set_size);static int __blkdev_get (struct block_device *bdev,mode_t mode,unsigned flags,int for_part); +static int __blkdev_put (struct block_device *bdev,int for_part);static int do_open (struct block_device *bdev,struct file *file,int for_part) {
@@ -992,7 +993,7 @@ out_first: bdev->bd_disk =NULL ; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;if (bdev != bdev->bd_contains) -blkdev_put (bdev->bd_contains); +__blkdev_put (bdev->bd_contains,1 ); bdev->bd_contains =NULL ;put_disk (disk);module_put (owner);
Quoted 3 lines · On Thursday November 2, [email protected] wrote:
Don't leak a ->bd_part_count when the partition open fails with
-ENXIO.
Acked-by NeilBrown <[email protected]>
Thanks. It took me a while to see why that was a correct fix. I wasn't noticing the 'if (bdev != bdev->bd_contains)' which is only true after __blkdev_get(whole, ...., 1) has been called.
NeilBrown
Quoted 27 lines
Signed-off-by Peter Zijlstra <[email protected]>--- fs/block_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Index:
linux-2.6-mm/fs/block_dev.c
===================================================================fs/block_dev.c +2
-1@@ -907,6 +907,7 @@ EXPORT_SYMBOL(bd_set_size);static int __blkdev_get (struct block_device *bdev,mode_t mode,unsigned flags,int for_part); +static int __blkdev_put (struct block_device *bdev,int for_part);static int do_open (struct block_device *bdev,struct file *file,int for_part) {@@ -992,7 +993,7 @@ out_first: bdev->bd_disk =NULL ; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;if (bdev != bdev->bd_contains) -blkdev_put (bdev->bd_contains); +__blkdev_put (bdev->bd_contains,1 ); bdev->bd_contains =NULL ;put_disk (disk);module_put (owner);