Skip to contentSkip to conversation

cobalt: fix unchecked return values

PATCH New Pan Bian 1 participant 1 message Apr 23, 2017

Subsystems (2)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 cobalt: fix unchecked return values

From: Pan Bian <[email protected]>

Function pci_find_ext_capability() may return 0, which is an invalid address. In function cobalt_pcie_status_show(), its return value is used without validation. This patch adds checks to validate the return address.

---
 drivers/media/pci/cobalt/cobalt-driver.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/pci/cobalt/cobalt-driver.c +2 -0
index d5c911c..f8e173f 100644
@@ -205,6 +205,8 @@ void cobalt_pcie_status_show(struct cobalt *cobalt)
 
 	offset = pci_find_capability(pci_dev, PCI_CAP_ID_EXP);
 	bus_offset = pci_find_capability(pci_bus_dev, PCI_CAP_ID_EXP);
+	if (!offset || !bus_offset)
+		return;
 
 	/* Device */
 	pci_read_config_dword(pci_dev, offset + PCI_EXP_DEVCAP, &capa);
Signature · 1 line
1.9.1