[RFC PATCH v4 1/5] PCI: Handle NULL value inside pci_upstream_bridge()
From: Saheed O. Bolarinwa
Date: Sun Nov 07 2021 - 11:30:01 EST
Return NULL if a NULL pointer is passed into pci_upstream_bridge().
Signed-off-by: Saheed O. Bolarinwa <refactormyself@xxxxxxxxx>
---
include/linux/pci.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cd8aa6fce204..b087e0b9814e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -695,6 +695,9 @@ static inline bool pci_is_bridge(struct pci_dev *dev)
static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev)
{
+ if (!dev)
+ return NULL;
+
dev = pci_physfn(dev);
if (pci_is_root_bus(dev->bus))
return NULL;
--
2.20.1