mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Alison Schofield <alison.schofield@intel.com>,
	Hemanth Selam <hemanth.selam@gmail.com>
Cc: Dan Williams <djbw@kernel.org>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] nvdimm/pmem: Release gendisk on probe failure
Date: Fri, 23 Oct 2026 18:11:09 +0200	[thread overview]
Message-ID: <1fea2b63-b1aa-4b2e-992e-9dc0c973a1ac@wanadoo.fr> (raw)
In-Reply-To: <ar8Lc1-griI_TwS4@aschofie-mobl2.lan>

Le 02/10/2026 à 03:40, Alison Schofield a écrit :
> On Fri, Sep 11, 2026 at 01:55:43PM +0530, Hemanth Selam wrote:
>> pmem_attach_disk() allocates the gendisk with blk_alloc_disk() and hands
>> it to devres only once device_add_disk() has succeeded.  Until that
>> point the probe path owns the disk itself, which is why every failure
>> after the allocation jumps to the out: label and puts it there.
>>
>> The devm_init_badblocks() failure returns directly instead, so the disk
>> allocated a few lines earlier is never released.  Nothing releases it
>> afterwards either: the devres action that would have done so has not
>> been registered yet, so unbinding the namespace or destroying it does
>> not reach the disk, and it stays allocated along with its queue and its
>> bdev inode until the machine is rebooted.
>>
>> devm_init_badblocks() only fails when a single page allocation fails, so
>> reaching this at all needs memory exhaustion during namespace probe, and
>> because device_add_disk() has not run there is nothing user visible left
>> behind: no device node, no sysfs entry, only the leaked memory.
>>
>> Release the gendisk through the existing cleanup path on this failure.
>>
>> Fixes: 3dd60fb9d95d ("nvdimm/pmem: stop using q_usage_count as external pgmap refcount")
>> Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com>
> 
> 
> Applied to libnvdimm-for-next:
> https://git.kernel.org/nvdimm/nvdimm/c/855a46681e0b

Hi,

For the records and if it sounds better patch, see [1] which propagates 
the error code from devm_init_badblocks() instead of hard-coding a -ENOMEM;

CJ

[1]: 
https://lore.kernel.org/lkml/f1933a01d9cefe24970ee93d741babb8fe9c1b32.1636219557.git.christophe.jaillet@wanadoo.fr/ 


  reply	other threads:[~2026-10-23 16:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  8:25 Hemanth Selam
2026-09-18 17:04 ` Dave Jiang
2026-10-02  1:40 ` Alison Schofield
2026-10-23 16:11   ` Christophe JAILLET [this message]
2026-10-23 16:42     ` Alison Schofield
  -- strict thread matches above, loose matches on Subject: below --
2026-08-31  4:34 Hemanth Selam
     [not found] ` <20260831044508.520351F000E9@smtp.kernel.org>
2026-08-31  5:02   ` Hemanth Selam

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=1fea2b63-b1aa-4b2e-992e-9dc0c973a1ac@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=djbw@kernel.org \
    --cc=hemanth.selam@gmail.com \
    --cc=ira.weiny@intel.com \
    --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®