diff mbox series

[09/10] loop: add error handling support for add_disk()

Message ID 20210823202930.137278-10-mcgrof@kernel.org
State Superseded
Headers show
Series block: first batch of add_disk() error handling conversions | expand

Commit Message

Luis Chamberlain Aug. 23, 2021, 8:29 p.m. UTC
We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Aug. 24, 2021, 6:25 a.m. UTC | #1
On Mon, Aug 23, 2021 at 01:29:29PM -0700, Luis Chamberlain wrote:
> We never checked for errors on add_disk() as this function

> returned void. Now that this is fixed, use the shiny new

> error handling.

> 

> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

> Signed-off-by: Christoph Hellwig <hch@lst.de>


Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


and I think you can drop my signoff.  I added this when I planned
to send out with the original conversion, but dropped it for simpler
examples.
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index fa1c298a8cfb..b8b9e2349e77 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2393,10 +2393,17 @@  static int loop_add(int i)
 	disk->events		= DISK_EVENT_MEDIA_CHANGE;
 	disk->event_flags	= DISK_EVENT_FLAG_UEVENT;
 	sprintf(disk->disk_name, "loop%d", i);
-	add_disk(disk);
+
+	err = add_disk(disk);
+	if (err)
+		goto out_cleanup_disk;
+
 	mutex_unlock(&loop_ctl_mutex);
+
 	return i;
 
+out_cleanup_disk:
+	blk_cleanup_disk(disk);
 out_cleanup_tags:
 	blk_mq_free_tag_set(&lo->tag_set);
 out_free_idr: