diff mbox series

[3/3] PCI: Update variable type to match sscanf() format string

Message ID 20211008222732.2868493-3-kw@linux.com (mailing list archive)
State Accepted
Delegated to: Bjorn Helgaas
Headers show
Series [1/3] PCI: hv: Remove unnecessary integer promotion from dev_err() | expand

Commit Message

Krzysztof Wilczyński Oct. 8, 2021, 10:27 p.m. UTC
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 mbox series

Patch

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;