summaryrefslogtreecommitdiff
path: root/drivers/media/pci/cobalt
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2017-04-23 15:18:29 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-06-06 13:29:15 +0300
commitb9150e8131914df75d396a5730a599d358f016d8 (patch)
tree653de1141824cf79a85814bb054c1a538966d64a /drivers/media/pci/cobalt
parent13174c388a76005c1abe454e47a37cd57edd8c8d (diff)
downloadlinux-b9150e8131914df75d396a5730a599d358f016d8.tar.xz
[media] cobalt: fix unchecked return values
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. Signed-off-by: Pan Bian <bianpan2016@163.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/pci/cobalt')
-rw-r--r--drivers/media/pci/cobalt/cobalt-driver.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
index d5c911c09e2b..f8e173f3e9e2 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -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);