diff options
author | Luis Chamberlain <mcgrof@kernel.org> | 2021-11-03 16:04:29 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-11-04 05:48:50 -0600 |
commit | 5a192ccc32e2981f721343c750b8cfb4c3f41007 (patch) | |
tree | e1fbde99aea2d1af47f1dd33368625dd5890a34e /drivers/nvdimm | |
parent | accf58afb689f81daadde24080ea1164ad2db75f (diff) |
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@lst.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20211103230437.1639990-7-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/nvdimm')
-rw-r--r-- | drivers/nvdimm/pmem.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index cbb3662391c2..6052091f6f59 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -491,7 +491,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; @@ -502,6 +504,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; |