[media] cobalt: fix unchecked return values
authorPan Bian <bianpan2016@163.com>
Sun, 23 Apr 2017 12:18:29 +0000 (09:18 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 6 Jun 2017 10:29:15 +0000 (07:29 -0300)
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>
drivers/media/pci/cobalt/cobalt-driver.c

index d5c911c09e2b792e767970f32c463862617cec19..f8e173f3e9e2ec1b6e05e92ba0e0119f283dbcc1 100644 (file)
@@ -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);