* [PATCH v2] nvdimm/pmem: Propagate devm_init_badblocks() error code
@ 2026-10-23 19:35 Christophe JAILLET
2026-12-03 1:34 ` Alison Schofield
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2026-10-23 19:35 UTC (permalink / raw)
To: hemanth.selam, Dan Williams, Vishal Verma, Dave Jiang,
Alison Schofield, Ira Weiny
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, nvdimm
Propagate errors from devm_init_badblocks() instead of hard-coding a
-ENOMEM.
This change is a no-op. The sanity check in devm_init_badblocks() can't
fail, so -EINVAL can't be returned. And __badblocks_init() can only return
0 or -ENOMEM.
However, propagating the error code is cleaner and more future proof.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Changes in v2:
- rebase with -next-20261023
- Update the commit summary and description. It is not a fix anymore,
just a clean-up. The Fix itself has already been applied in commit
855a46681e0b ("nvdimm/pmem: Release gendisk on probe failure")
v1 (from 2021!):
- https://lore.kernel.org/lkml/f1933a01d9cefe24970ee93d741babb8fe9c1b32.1636219557.git.christophe.jaillet@wanadoo.fr/
---
drivers/nvdimm/pmem.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 0766a6949b28..76e80eccc8e7 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -563,10 +563,9 @@ static int pmem_attach_disk(struct device *dev,
nvdimm_namespace_disk_name(ndns, disk->disk_name);
set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
/ 512);
- if (devm_init_badblocks(dev, &pmem->bb)) {
- rc = -ENOMEM;
+ rc = devm_init_badblocks(dev, &pmem->bb);
+ if (rc)
goto out;
- }
nvdimm_badblocks_populate(nd_region, &pmem->bb, &bb_range);
disk->bb = &pmem->bb;
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] nvdimm/pmem: Propagate devm_init_badblocks() error code
2026-10-23 19:35 [PATCH v2] nvdimm/pmem: Propagate devm_init_badblocks() error code Christophe JAILLET
@ 2026-12-03 1:34 ` Alison Schofield
0 siblings, 0 replies; 2+ messages in thread
From: Alison Schofield @ 2026-12-03 1:34 UTC (permalink / raw)
To: Christophe JAILLET
Cc: hemanth.selam, Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny,
linux-kernel, kernel-janitors, nvdimm
On Fri, Oct 23, 2026 at 09:35:40PM +0200, Christophe JAILLET wrote:
> Propagate errors from devm_init_badblocks() instead of hard-coding a
> -ENOMEM.
>
> This change is a no-op. The sanity check in devm_init_badblocks() can't
> fail, so -EINVAL can't be returned. And __badblocks_init() can only return
> 0 or -ENOMEM.
>
> However, propagating the error code is cleaner and more future proof.
Thanks, Christophe. I’m taking the patch with a small commit message edit.
I dropped “cleaner and more future proof” because the cleanup is straight-
forward to describe: pmem_attach_disk() can use the helper’s return value
directly. -ENOMEM is still the only error this call can return today.
Applied to libnvdimm-for-next:
https://git.kernel.org/nvdimm/nvdimm/c/3860f1f60537
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 1:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 19:35 [PATCH v2] nvdimm/pmem: Propagate devm_init_badblocks() error code Christophe JAILLET
2026-12-03 1:34 ` Alison Schofield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®