* [PATCH] nvme-pci: return -EINVAL when failing to parse quirk parameter
@ 2026-08-15 13:47 Sreeraj S Kurup
2026-08-17 7:00 ` Christoph Hellwig
2026-08-19 15:02 ` Keith Busch
0 siblings, 2 replies; 3+ messages in thread
From: Sreeraj S Kurup @ 2026-08-15 13:47 UTC (permalink / raw)
To: kbusch, hch, sagi, axboe; +Cc: linux-nvme, linux-kernel, Sreeraj S Kurup
In quirks_param_set(), if nvme_parse_quirk_entry() fails to parse an
entry from the user-provided quirks string, the function prints an
error message with pr_err() and jumps to out_free_qlist to free
resources.
However, the variable 'err' is not updated upon parse failure,
retaining the value '0' from the preceding call to
param_set_copystring(). As a result, quirks_param_set() frees the
allocated memory but returns 0 (success) to the kernel parameter
subsystem, silently masking the parsing failure and incorrectly
reporting success to the caller.
Fix this by explicitly setting 'err = -EINVAL;' before jumping to
out_free_qlist, ensuring that parse failures are correctly propagated
to the caller.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.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 69932d640b53..560560268c05 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -213,6 +213,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
if (nvme_parse_quirk_entry(field, &qlist[i])) {
pr_err("nvme: failed to parse quirk string %s\n",
value);
+ err = -EINVAL;
goto out_free_qlist;
}
--
2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nvme-pci: return -EINVAL when failing to parse quirk parameter
2026-08-15 13:47 [PATCH] nvme-pci: return -EINVAL when failing to parse quirk parameter Sreeraj S Kurup
@ 2026-08-17 7:00 ` Christoph Hellwig
2026-08-19 15:02 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-08-17 7:00 UTC (permalink / raw)
To: Sreeraj S Kurup; +Cc: kbusch, hch, sagi, axboe, linux-nvme, linux-kernel
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme-pci: return -EINVAL when failing to parse quirk parameter
2026-08-15 13:47 [PATCH] nvme-pci: return -EINVAL when failing to parse quirk parameter Sreeraj S Kurup
2026-08-17 7:00 ` Christoph Hellwig
@ 2026-08-19 15:02 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2026-08-19 15:02 UTC (permalink / raw)
To: Sreeraj S Kurup; +Cc: hch, sagi, axboe, linux-nvme, linux-kernel
On Sat, Aug 15, 2026 at 01:47:45PM +0000, Sreeraj S Kurup wrote:
> In quirks_param_set(), if nvme_parse_quirk_entry() fails to parse an
> entry from the user-provided quirks string, the function prints an
> error message with pr_err() and jumps to out_free_qlist to free
> resources.
>
> However, the variable 'err' is not updated upon parse failure,
> retaining the value '0' from the preceding call to
> param_set_copystring(). As a result, quirks_param_set() frees the
> allocated memory but returns 0 (success) to the kernel parameter
> subsystem, silently masking the parsing failure and incorrectly
> reporting success to the caller.
>
> Fix this by explicitly setting 'err = -EINVAL;' before jumping to
> out_free_qlist, ensuring that parse failures are correctly propagated
> to the caller.
This fix was submitted earlier:
https://lore.kernel.org/linux-nvme/20260729105958.1403095-1-kanie@linux.alibaba.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-19 15:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-15 13:47 [PATCH] nvme-pci: return -EINVAL when failing to parse quirk parameter Sreeraj S Kurup
2026-08-17 7:00 ` Christoph Hellwig
2026-08-19 15:02 ` Keith Busch
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®