Skip to content

Commit

Permalink
z2ram: add error handling support for add_disk()
Browse files Browse the repository at this point in the history
We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling. Only the disk is cleaned up inside
z2ram_register_disk() as the caller deals with the rest.

Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Luis Chamberlain <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
mcgrof authored and axboe committed Nov 4, 2021
1 parent 5a192cc commit 1573375
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/block/z2ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ static const struct blk_mq_ops z2_mq_ops = {
static int z2ram_register_disk(int minor)
{
struct gendisk *disk;
int err;

disk = blk_mq_alloc_disk(&tag_set, NULL);
if (IS_ERR(disk))
Expand All @@ -333,8 +334,10 @@ static int z2ram_register_disk(int minor)
sprintf(disk->disk_name, "z2ram");

z2ram_gendisk[minor] = disk;
add_disk(disk);
return 0;
err = add_disk(disk);
if (err)
blk_cleanup_disk(disk);
return err;
}

static int __init z2_init(void)
Expand Down

0 comments on commit 1573375

Please sign in to comment.