[bug report] nvme: add support for dynamic quirk configuration via module parameter
Maurizio Lombardi
mlombard at arkamax.eu
Fri Apr 10 04:28:55 PDT 2026
Hello Dan,
On Fri Apr 10, 2026 at 12:13 PM CEST, Dan Carpenter wrote:
> Hello Maurizio Lombardi,
>
> Commit 7bb8c40f5ad8 ("nvme: add support for dynamic quirk
> configuration via module parameter") from Feb 4, 2026 (linux-next),
> leads to the following Smatch static checker warning:
>
> drivers/nvme/host/pci.c:216 quirks_param_set()
> warn: missing error code here? 'nvme_parse_quirk_entry()' failed. 'err' = '0'
Thanks for reporting this.
I didn't want to propagate the error code here, preventing the nvme-pci
kernel module from loading (and potentially making the machine
unbootable) just because the user misspelled a quirk's name.
In my opinion an error message in dmesg is sufficient, therefore I will
not fix this unless the maintainers have a different opinion.
Thanks,
Maurizio
>
> drivers/nvme/host/pci.c
> 181 static int quirks_param_set(const char *value, const struct kernel_param *kp)
> 182 {
> 183 int count, err, i;
> 184 struct quirk_entry *qlist;
> 185 char *field, *val, *sep_ptr;
> 186
> 187 err = param_set_copystring(value, kp);
> 188 if (err)
> 189 return err;
> 190
> 191 val = kstrdup(value, GFP_KERNEL);
> 192 if (!val)
> 193 return -ENOMEM;
> 194
> 195 if (!*val)
> 196 goto out_free_val;
> 197
> 198 count = 1;
> 199 for (i = 0; val[i]; i++) {
> 200 if (val[i] == '-')
> 201 count++;
> 202 }
> 203
> 204 qlist = kcalloc(count, sizeof(*qlist), GFP_KERNEL);
> 205 if (!qlist) {
> 206 err = -ENOMEM;
> 207 goto out_free_val;
> 208 }
> 209
> 210 i = 0;
> 211 sep_ptr = val;
> 212 while ((field = strsep(&sep_ptr, "-"))) {
> 213 if (nvme_parse_quirk_entry(field, &qlist[i])) {
> 214 pr_err("nvme: failed to parse quirk string %s\n",
> 215 value);
> --> 216 goto out_free_qlist;
>
> Propagate the error code from nvme_parse_quirk_entry()?
>
> 217 }
> 218
> 219 i++;
> 220 }
> 221
> 222 kfree(nvme_pci_quirk_list);
> 223 nvme_pci_quirk_count = count;
> 224 nvme_pci_quirk_list = qlist;
> 225 goto out_free_val;
> 226
> 227 out_free_qlist:
> 228 kfree(qlist);
> 229 out_free_val:
> 230 kfree(val);
> 231 return err;
> 232 }
>
> This email is a free service from the Smatch-CI project [smatch.sf.net].
>
> regards,
> dan carpenter
More information about the Linux-nvme
mailing list