s390/block/dcssblk: add error handling support for add_disk()
authorGerald Schaefer <gerald.schaefer@linux.ibm.com>
Mon, 27 Sep 2021 22:02:31 +0000 (15:02 -0700)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 4 Oct 2021 07:49:37 +0000 (09:49 +0200)
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>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Link: https://lore.kernel.org/r/20210927220232.1071926-6-mcgrof@kernel.org
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/block/dcssblk.c

index 5be3d1c39a78eeb1c5991fd2030453c455600cac..0741a93217122a6ce2f5bf0a48a683d3e4540ad8 100644 (file)
@@ -696,7 +696,9 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
        }
 
        get_device(&dev_info->dev);
-       device_add_disk(&dev_info->dev, dev_info->gd, NULL);
+       rc = device_add_disk(&dev_info->dev, dev_info->gd, NULL);
+       if (rc)
+               goto out_dax;
 
        switch (dev_info->segment_type) {
                case SEG_TYPE_SR:
@@ -712,6 +714,10 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
        rc = count;
        goto out;
 
+out_dax:
+       put_device(&dev_info->dev);
+       kill_dax(dev_info->dax_dev);
+       put_dax(dev_info->dax_dev);
 put_dev:
        list_del(&dev_info->lh);
        blk_cleanup_disk(dev_info->gd);