From: Dinghao Liu Date: Sun, 17 Jan 2021 08:50:17 +0000 (+0800) Subject: block: Fix an error handling in add_partition X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ef49d40b61a3e18a11edd5eb1c30b0183af9e850;p=linux.git block: Fix an error handling in add_partition Once we have called device_initialize(), we should use put_device() to give up the reference on error, just like what we have done on failure of device_add(). Signed-off-by: Dinghao Liu Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe --- diff --git a/block/partitions/core.c b/block/partitions/core.c index e7d776db803b1..23460cee9de50 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -384,7 +384,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, err = blk_alloc_devt(bdev, &devt); if (err) - goto out_bdput; + goto out_put; pdev->devt = devt; /* delay uevent until 'holders' subdir is created */