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@xxxxxxxxxx> --- drivers/block/loop.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 6dccba22c9b5..dcb126f3a7e1 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2096,10 +2096,15 @@ static int loop_add(struct loop_device **l, int i) disk->private_data = lo; disk->queue = lo->lo_queue; sprintf(disk->disk_name, "loop%d", i); - add_disk(disk); + err = add_disk(disk); + if (err) + goto out_put_disk; + *l = lo; return lo->lo_number; +out_put_disk: + put_disk(lo->lo_disk); out_free_queue: blk_cleanup_queue(lo->lo_queue); out_cleanup_tags: -- 2.25.1