[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 10/10] 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@xxxxxxxxxx>
 drivers/block/zram/zram_drv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index f61910c65f0f..59086e178fbd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1953,7 +1953,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));
@@ -1961,6 +1963,8 @@ static int zram_add(void)
        pr_info("Added device: %s\n", zram->disk->disk_name);
        return device_id;
+       blk_cleanup_disk(zram->disk);
        idr_remove(&zram_index_idr, device_id);



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.