Message ID | 20211103174521.1426407-9-mcgrof@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: add_disk() error handling stragglers | expand |
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 4eef218108c6..ccc52c935faf 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -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)) @@ -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)