Skip to content

Commit dc104f4

Browse files
mcgrofaxboe
authored andcommitted
nvdimm/blk: 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. Since nvdimm/blk uses devm we just need to move the devm registration towards the end. And in hindsight, that seems to also provide a fix given del_gendisk() should not be called unless the disk was already added via add_disk(). The probably of that issue happening is low though, like OOM while calling devm_add_action(), so the fix is minor. We manually unwind in case of add_disk() failure prior to the devm registration. Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent b7421af commit dc104f4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/nvdimm/blk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
264264
}
265265

266266
set_capacity(disk, available_disk_size >> SECTOR_SHIFT);
267-
device_add_disk(dev, disk, NULL);
267+
rc = device_add_disk(dev, disk, NULL);
268+
if (rc)
269+
goto out_before_devm_err;
268270

269271
/* nd_blk_release_disk() is called if this fails */
270272
if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk))

0 commit comments

Comments
 (0)