public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [bug report] nvme: add support for dynamic quirk configuration via module parameter
@ 2026-04-10 10:13 Dan Carpenter
  2026-04-10 11:28 ` Maurizio Lombardi
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2026-04-10 10:13 UTC (permalink / raw)
  To: Maurizio Lombardi; +Cc: linux-nvme

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'

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] nvme: add support for dynamic quirk configuration via module parameter
  2026-04-10 10:13 [bug report] nvme: add support for dynamic quirk configuration via module parameter Dan Carpenter
@ 2026-04-10 11:28 ` Maurizio Lombardi
  0 siblings, 0 replies; 2+ messages in thread
From: Maurizio Lombardi @ 2026-04-10 11:28 UTC (permalink / raw)
  To: Dan Carpenter, Maurizio Lombardi; +Cc: linux-nvme

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-10 11:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 10:13 [bug report] nvme: add support for dynamic quirk configuration via module parameter Dan Carpenter
2026-04-10 11:28 ` Maurizio Lombardi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox