diff options
| author | Maurizio Lombardi <mlombard@redhat.com> | 2026-02-11 19:30:28 +0300 |
|---|---|---|
| committer | Keith Busch <kbusch@kernel.org> | 2026-02-12 05:34:39 +0300 |
| commit | bbdaa8c17cae18b977f4509911d7a390aa8a6597 (patch) | |
| tree | 3317da2a84b83320c5b1abd8d42b5f0a3d3d3af6 | |
| parent | 3ddfbfbc78ac1d3d9e95098fb6a32b57b8a0dcae (diff) | |
| download | linux-bbdaa8c17cae18b977f4509911d7a390aa8a6597.tar.xz | |
nvme: fix memory leak in quirks_param_set()
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")
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
| -rw-r--r-- | drivers/nvme/host/pci.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index bd884e294600..c0f2104326ab 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; |
