Skip to content

Commit accf58a

Browse files
mcgrofaxboe
authored andcommitted
nvdimm/pmem: cleanup the disk if pmem_release_disk() is yet assigned
Prior to devm being able to use pmem_release_disk() there are other failure which can occur for which we must account for and release the disk for. Address those few cases. Fixes: 3dd60fb ("nvdimm/pmem: stop using q_usage_count as external pgmap refcount") Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Link: https://lore.kernel.org/r/20211103230437.1639990-6-mcgrof@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent dc104f4 commit accf58a

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

drivers/nvdimm/pmem.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,10 @@ static int pmem_attach_disk(struct device *dev,
457457
bb_range.end = res->end;
458458
}
459459

460-
if (IS_ERR(addr))
461-
return PTR_ERR(addr);
460+
if (IS_ERR(addr)) {
461+
rc = PTR_ERR(addr);
462+
goto out;
463+
}
462464
pmem->virt_addr = addr;
463465

464466
blk_queue_write_cache(q, true, fua);
@@ -483,7 +485,8 @@ static int pmem_attach_disk(struct device *dev,
483485
flags = DAXDEV_F_SYNC;
484486
dax_dev = alloc_dax(pmem, disk->disk_name, &pmem_dax_ops, flags);
485487
if (IS_ERR(dax_dev)) {
486-
return PTR_ERR(dax_dev);
488+
rc = PTR_ERR(dax_dev);
489+
goto out;
487490
}
488491
dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
489492
pmem->dax_dev = dax_dev;
@@ -498,8 +501,10 @@ static int pmem_attach_disk(struct device *dev,
498501
"badblocks");
499502
if (!pmem->bb_state)
500503
dev_warn(dev, "'badblocks' notification disabled\n");
501-
502504
return 0;
505+
out:
506+
blk_cleanup_disk(pmem->disk);
507+
return rc;
503508
}
504509

505510
static int nd_pmem_probe(struct device *dev)

0 commit comments

Comments
 (0)