summaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-09-27 15:02:30 -0700
committerVasily Gorbik <gor@linux.ibm.com>2021-10-04 09:49:37 +0200
commit11dfe199eb31079a6f2517a59c380ad55f156696 (patch)
tree6e4f1beacf4b3d54f11da4aa20ee9876297630cf /drivers/s390
parente3ec8e0f5711d73f7e5d5c3cffdf4fad4f1487b9 (diff)
downloadlinux-11dfe199eb31079a6f2517a59c380ad55f156696.tar.gz
linux-11dfe199eb31079a6f2517a59c380ad55f156696.tar.bz2
linux-11dfe199eb31079a6f2517a59c380ad55f156696.zip
s390/block/dasd_genhd: 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. Be sure to call dasd_gendisk_free() on error. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Link: https://lore.kernel.org/r/20210927220232.1071926-5-mcgrof@kernel.org Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/block/dasd_genhd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index fa966e0db6ca..80673dbfb1f9 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -33,7 +33,7 @@ int dasd_gendisk_alloc(struct dasd_block *block)
{
struct gendisk *gdp;
struct dasd_device *base;
- int len;
+ int len, rc;
/* Make sure the minor for this device exists. */
base = block->base;
@@ -79,7 +79,13 @@ int dasd_gendisk_alloc(struct dasd_block *block)
dasd_add_link_to_gendisk(gdp, base);
block->gdp = gdp;
set_capacity(block->gdp, 0);
- device_add_disk(&base->cdev->dev, block->gdp, NULL);
+
+ rc = device_add_disk(&base->cdev->dev, block->gdp, NULL);
+ if (rc) {
+ dasd_gendisk_free(block);
+ return rc;
+ }
+
return 0;
}