Skip to content

Commit bbdaa8c

Browse files
maurizio-lombardikeithbusch
authored andcommitted
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>
1 parent 3ddfbfb commit bbdaa8c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/nvme/host/pci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
219219
i++;
220220
}
221221

222+
kfree(nvme_pci_quirk_list);
222223
nvme_pci_quirk_count = count;
223224
nvme_pci_quirk_list = qlist;
224225
goto out_free_val;

0 commit comments

Comments
 (0)