Skip to content

Commit 1573375

Browse files
mcgrofaxboe
authored andcommitted
z2ram: add error handling support for add_disk()
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]>
1 parent 5a192cc commit 1573375

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/block/z2ram.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ static const struct blk_mq_ops z2_mq_ops = {
318318
static int z2ram_register_disk(int minor)
319319
{
320320
struct gendisk *disk;
321+
int err;
321322

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

335336
z2ram_gendisk[minor] = disk;
336-
add_disk(disk);
337-
return 0;
337+
err = add_disk(disk);
338+
if (err)
339+
blk_cleanup_disk(disk);
340+
return err;
338341
}
339342

340343
static int __init z2_init(void)

0 commit comments

Comments
 (0)