diff mbox series

[21/44] block: move bdput() to the callers of __blkdev_get

Message ID 20201126130422.92945-22-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/44] blk-cgroup: fix a hd_struct leak in blkcg_fill_root_iostats | expand

Commit Message

Christoph Hellwig Nov. 26, 2020, 1:03 p.m. UTC
This will allow for a more symmetric calling convention going forward.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jan Kara Nov. 26, 2020, 3:05 p.m. UTC | #1
On Thu 26-11-20 14:03:59, Christoph Hellwig wrote:
> This will allow for a more symmetric calling convention going forward.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good to me. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/block_dev.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 86a61a2141f642..d0783c55a0ce65 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1458,6 +1458,7 @@ static int __blkdev_get(struct block_device *bdev, struct gendisk *disk,
>  			if (!(disk->flags & GENHD_FL_UP) ||
>  			    !bdev->bd_part || !bdev->bd_part->nr_sects) {
>  				__blkdev_put(whole, mode, 1);
> +				bdput(whole);
>  				ret = -ENXIO;
>  				goto out_clear;
>  			}
> @@ -1740,9 +1741,10 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
>  			disk->fops->release(disk, mode);
>  	}
>  	mutex_unlock(&bdev->bd_mutex);
> -	bdput(bdev);
> -	if (victim)
> +	if (victim) {
>  		__blkdev_put(victim, mode, 1);
> +		bdput(victim);
> +	}
>  }
>  
>  void blkdev_put(struct block_device *bdev, fmode_t mode)
> @@ -1792,6 +1794,7 @@ void blkdev_put(struct block_device *bdev, fmode_t mode)
>  	mutex_unlock(&bdev->bd_mutex);
>  
>  	__blkdev_put(bdev, mode, 0);
> +	bdput(bdev);
>  	put_disk_and_module(disk);
>  }
>  EXPORT_SYMBOL(blkdev_put);
> -- 
> 2.29.2
>
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 86a61a2141f642..d0783c55a0ce65 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1458,6 +1458,7 @@  static int __blkdev_get(struct block_device *bdev, struct gendisk *disk,
 			if (!(disk->flags & GENHD_FL_UP) ||
 			    !bdev->bd_part || !bdev->bd_part->nr_sects) {
 				__blkdev_put(whole, mode, 1);
+				bdput(whole);
 				ret = -ENXIO;
 				goto out_clear;
 			}
@@ -1740,9 +1741,10 @@  static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
 			disk->fops->release(disk, mode);
 	}
 	mutex_unlock(&bdev->bd_mutex);
-	bdput(bdev);
-	if (victim)
+	if (victim) {
 		__blkdev_put(victim, mode, 1);
+		bdput(victim);
+	}
 }
 
 void blkdev_put(struct block_device *bdev, fmode_t mode)
@@ -1792,6 +1794,7 @@  void blkdev_put(struct block_device *bdev, fmode_t mode)
 	mutex_unlock(&bdev->bd_mutex);
 
 	__blkdev_put(bdev, mode, 0);
+	bdput(bdev);
 	put_disk_and_module(disk);
 }
 EXPORT_SYMBOL(blkdev_put);