[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211103174521.1426407-8-mcgrof@kernel.org>
Date: Wed, 3 Nov 2021 10:45:15 -0700
From: Luis Chamberlain <mcgrof@...nel.org>
To: axboe@...nel.dk, hch@....de, penguin-kernel@...ove.sakura.ne.jp,
dan.j.williams@...el.com, vishal.l.verma@...el.com,
dave.jiang@...el.com, ira.weiny@...el.com, richard@....at,
miquel.raynal@...tlin.com, vigneshr@...com, efremov@...ux.com,
song@...nel.org, martin.petersen@...cle.com, hare@...e.de,
jack@...e.cz, ming.lei@...hat.com, tj@...nel.org, mcgrof@...nel.org
Cc: linux-mtd@...ts.infradead.org, linux-scsi@...r.kernel.org,
linux-raid@...r.kernel.org, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 07/13] nvdimm/pmem: use add_disk() error handling
Now that device_add_disk() supports returning an error, use
that. We must unwind alloc_dax() on error.
Reviewed-by: Christoph Hellwig <hch@....de>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
drivers/nvdimm/pmem.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index d98af6c31f42..fe7ece1534e1 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -505,7 +505,9 @@ static int pmem_attach_disk(struct device *dev,
dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
pmem->dax_dev = dax_dev;
- device_add_disk(dev, disk, pmem_attribute_groups);
+ rc = device_add_disk(dev, disk, pmem_attribute_groups);
+ if (rc)
+ goto out_cleanup_dax;
if (devm_add_action_or_reset(dev, pmem_release_disk, pmem))
return -ENOMEM;
@@ -516,6 +518,10 @@ static int pmem_attach_disk(struct device *dev,
if (!pmem->bb_state)
dev_warn(dev, "'badblocks' notification disabled\n");
return 0;
+
+out_cleanup_dax:
+ kill_dax(pmem->dax_dev);
+ put_dax(pmem->dax_dev);
out:
blk_cleanup_disk(pmem->disk);
return rc;
--
2.33.0
Powered by blists - more mailing lists