diff options
author | Luis Chamberlain <mcgrof@kernel.org> | 2021-10-15 16:52:14 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-10-30 11:03:37 -0600 |
commit | 5e2e1cc4131cf4d21629c94331f2351b7dc8b87c (patch) | |
tree | 3d491e63050115679a219ac25620353d6702d776 /drivers/block/zram | |
parent | 15dfc662ef31a20b59097d59b0792b06770255fa (diff) | |
download | linux-5e2e1cc4131cf4d21629c94331f2351b7dc8b87c.tar.bz2 |
zram: 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.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Minchan Kim <minchan@kernel.org>
Link: https://lore.kernel.org/r/20211015235219.2191207-9-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/zram')
-rw-r--r-- | drivers/block/zram/zram_drv.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index a68297fb51a2..876bf191e2ca 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1949,7 +1949,9 @@ static int zram_add(void) blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX); blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, zram->disk->queue); - device_add_disk(NULL, zram->disk, zram_disk_attr_groups); + ret = device_add_disk(NULL, zram->disk, zram_disk_attr_groups); + if (ret) + goto out_cleanup_disk; strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); @@ -1957,6 +1959,8 @@ static int zram_add(void) pr_info("Added device: %s\n", zram->disk->disk_name); return device_id; +out_cleanup_disk: + blk_cleanup_disk(zram->disk); out_free_idr: idr_remove(&zram_index_idr, device_id); out_free_dev: |