From: Maurizio Lombardi <mlombard@redhat.com>
To: kbusch@kernel.org
Cc: hch@lst.de, linux-nvme@lists.infradead.org, dwagner@suse.de,
mlombard@bsdbackstore.eu
Subject: [PATCH] nvme: fix memory leak in quirks_param_set()
Date: Wed, 11 Feb 2026 17:30:28 +0100 [thread overview]
Message-ID: <20260211163028.76913-1-mlombard@redhat.com> (raw)
When loading the nvme module, if the 'quirks' parameter is specified
via both the kernel command line (e.g., nvme.quirks=...) and the
modprobe command line (e.g., modprobe nvme quirks=...), the
quirks_param_set() callback is invoked twice.
Currently, in the double-invocation scenario, the second call
overwrites the nvme_pci_quirk_list pointer, causing the memory
allocated in the first call to leak.
Fix this by freeing the existing list before assigning the new one.
Fixes: b4247c8317c5 ("nvme: add support for dynamic quirk configuration via module parameter")
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
drivers/nvme/host/pci.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index a6cf0897a0f2..3e1c6adf2cf0 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -219,6 +219,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
i++;
}
+ kfree(nvme_pci_quirk_list);
nvme_pci_quirk_count = count;
nvme_pci_quirk_list = qlist;
goto out_free_val;
--
2.53.0
next reply other threads:[~2026-02-11 16:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 16:30 Maurizio Lombardi [this message]
2026-02-11 16:41 ` [PATCH] nvme: fix memory leak in quirks_param_set() Christoph Hellwig
2026-02-11 17:01 ` Daniel Wagner
2026-02-12 2:35 ` Keith Busch
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=20260211163028.76913-1-mlombard@redhat.com \
--to=mlombard@redhat.com \
--cc=dwagner@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mlombard@bsdbackstore.eu \
/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