Thread (6 messages) 6 messages, 2 authors, 2021-10-13

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

flat view
STALE1834d LANDED

From: Krzysztof Wilczyński <hidden>
Date: 2021-10-08 22:27:39
Also in: linux-pci
Subsystem: pci subsystem, the rest · Maintainers: Bjorn Helgaas, Linus Torvalds

Landed in mainline as 357df2fc0066 on 2021-10-12.

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help