From: mdshahid03@gmail.com
To: djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com,
alison.schofield@intel.com
Cc: iweiny@kernel.org, nvdimm@lists.linux.dev,
linux-kernel@vger.kernel.org,
Mohammad Shahid <mdshahid03@gmail.com>
Subject: [PATCH] nvdimm/pmem: Fix disk resource cleanup on initialization failure
Date: Wed, 4 Nov 2026 21:48:25 +0530 [thread overview]
Message-ID: <20261104161825.314835-1-mdshahid03@gmail.com> (raw)
From: Mohammad Shahid <mdshahid03@gmail.com>
pmem_attach_disk() allocates a disk using blk_alloc_disk()
before initializing badblocks.
If devm_init_badblocks() fails, the function return directly
without releasing the previously allocated disk.
Use the existing cleanup path to release the disk and preserve
the original error code returned by devm_init_badblocks().
Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
drivers/nvdimm/pmem.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 5fb86595e8bd..76e80eccc8e7 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -563,8 +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))
- return -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.43.0
reply other threads:[~2026-11-04 16:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104161825.314835-1-mdshahid03@gmail.com \
--to=mdshahid03@gmail.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=iweiny@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®