Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wei Wang" <wei.w.wang@hotmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v7 3/6] PCI: Consolidate delimiter handling into pci_dev_str_match()
Date: Wed, 06 May 2026 20:37:06 +0000	[thread overview]
Message-ID: <20260506203707.3E69AC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <SI2PR01MB43933D93A8B638C86C84D405DC3F2@SI2PR01MB4393.apcprd01.prod.exchangelabs.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] When path-based parsing fails, the error message logs the remaining parameters (or an empty string) instead of the malformed parameter.
- [Medium] Replacing a rate-limited print with an unconditional `pr_err()` causes severe boot log spam for malformed parameters.
--

commit aaf5aed76bd0649688730dce72d818789919c430
Author: Wei Wang <wei.w.wang@hotmail.com>

PCI: Consolidate delimiter handling into pci_dev_str_match()

This commit moves the ';' or ',' delimiter checking logic directly into
pci_dev_str_match(), simplifying caller code. It also updates the function
to return -ENODEV when parsing reaches the end of the list or encounters an
invalid format.

> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e017200694d8a..ebd1e81264d21 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
[ ... ]
> @@ -397,16 +402,28 @@ static int pci_dev_str_match(struct pci_dev *dev, const char *p,
>  		 */
>  		ret = pci_dev_str_match_path(dev, p, &p);
>  		if (ret < 0)
> -			return ret;
> +			goto not_found;

In pci_dev_str_match_path(), the pointer p is advanced immediately:

static int pci_dev_str_match_path(struct pci_dev *dev, const char *path,
				  const char **endptr)
{
...
	*endptr = strchrnul(path, ';');

Since pci_dev_str_match() calls pci_dev_str_match_path(dev, p, &p), the local
pointer p is updated to the end of the parameter before returning an error.

When we jump to not_found, does this mean the pr_err() will print the
remaining parameters (or an empty string) instead of the malformed parameter?

>  		else if (ret)
>  			goto found;
>  	}
>  
> -	*endptr = p;
> -	return 0;
> +not_found:
> +	if (ret < 0)
> +		pr_err("PCI: Can't parse parameter: %s\n", p);

Because pci_dev_str_match() is evaluated for every PCI device during boot
enumeration (for example, through __pci_config_acs()), it is called
repeatedly.

Could this unconditional pr_err() cause severe boot log spam if a malformed
parameter is passed on the kernel command line?

The previous code in __pci_config_acs() used a rate-limited pr_warn_once(),
which this commit removed:

[ ... ]
> @@ -933,18 +950,11 @@ static void __pci_config_acs(struct pci_dev *dev, struct pci_acs *caps,
>  
>  		ret = pci_dev_str_match(dev, p, &p);
>  		if (ret < 0) {
> -			pr_warn_once("PCI: Can't parse ACS command line parameter\n");
>  			break;
>  		} else if (ret == 1) {
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/SI2PR01MB439385689A32A1DDA9CEABE1DC3F2@SI2PR01MB4393.apcprd01.prod.exchangelabs.com?part=3

  parent reply	other threads:[~2026-05-06 20:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 14:10 [PATCH v7 0/6] PCI: Add support for ACS Enhanced Capability Wei Wang
2026-05-06 14:10 ` [PATCH v7 1/6] PCI: Validate ACS enable flags against device-specific ACS capabilities Wei Wang
2026-05-06 20:01   ` sashiko-bot
2026-05-06 14:10 ` [PATCH v7 2/6] Documentation/kernel-parameters: Add multi-device config_acs example Wei Wang
2026-05-06 20:12   ` sashiko-bot
2026-05-06 22:06   ` Randy Dunlap
2026-05-07 13:45     ` Wei Wang
2026-05-06 14:10 ` [PATCH v7 3/6] PCI: Consolidate delimiter handling into pci_dev_str_match() Wei Wang
2026-05-06 16:13   ` Wei Wang
2026-05-06 20:37   ` sashiko-bot [this message]
2026-05-06 14:10 ` [PATCH v7 4/6] PCI: Refactor disable_acs_redir and config_acs param handling Wei Wang
2026-05-06 21:07   ` sashiko-bot
2026-05-06 14:10 ` [PATCH v7 5/6] PCI: Enable the enhanced ACS controls introduced by PCI_ACS_ECAP Wei Wang
2026-05-06 21:32   ` sashiko-bot
2026-05-06 14:10 ` [PATCH v7 6/6] PCI: Add the enhanced ACS controls check to pci_acs_flags_enabled() Wei Wang
2026-05-06 21:57   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260506203707.3E69AC2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko@lists.linux.dev \
    --cc=wei.w.wang@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox