From: "Krzysztof Wilczyński" <kw@linux.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Boqun Feng <boqun.feng@gmail.com>, Long Li <longli@microsoft.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org
Subject: [PATCH 3/3] PCI: Update variable type to match sscanf() format string
Date: Fri, 8 Oct 2021 22:27:32 +0000 [thread overview]
Message-ID: <20211008222732.2868493-3-kw@linux.com> (raw)
In-Reply-To: <20211008222732.2868493-1-kw@linux.com>
To test whether a string contains a valid PCI device path formatted as
the "/<device>.<function>" address (see output from "lspci -P" as an
example; such format can also be provided as part of kernel command-line
parameters), the function called pci_dev_str_match_path() can be used.
Internally, pci_dev_str_match_path() function uses sscanf() and the "%x"
format string as part of its path matching implementation where it would
parse a given value as a unsigned hexadecimal number. This particular
format string type requires the argument to be of an unsigned int type.
Thus, to match given format string requirements and also safeguard
against a potential undefined behaviour, change type of the variables
passed to sscanf() to unsigned int accordingly.
No change to functionality intended.
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
drivers/pci/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ce2ab62b64cf..7998b65e9ae5 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -269,7 +269,7 @@ static int pci_dev_str_match_path(struct pci_dev *dev, const char *path,
const char **endptr)
{
int ret;
- int seg, bus, slot, func;
+ unsigned int seg, bus, slot, func;
char *wpath, *p;
char end;
--
2.33.0
next prev parent reply other threads:[~2021-10-08 22:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-08 22:27 [PATCH 1/3] PCI: hv: Remove unnecessary integer promotion from dev_err() Krzysztof Wilczyński
2021-10-08 22:27 ` [PATCH 2/3] PCI: iov: Update format string type to match variable type Krzysztof Wilczyński
2021-10-11 21:13 ` Bjorn Helgaas
2021-10-08 22:27 ` Krzysztof Wilczyński [this message]
2021-10-12 18:47 ` [PATCH 1/3] PCI: hv: Remove unnecessary integer promotion from dev_err() Bjorn Helgaas
2021-10-13 0:43 ` Krzysztof Wilczyński
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=20211008222732.2868493-3-kw@linux.com \
--to=kw@linux.com \
--cc=bhelgaas@google.com \
--cc=boqun.feng@gmail.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=lorenzo.pieralisi@arm.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).