]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: chelsio: cxgb3: check the return value of pci_find_capability()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Fri, 25 Feb 2022 12:37:27 +0000 (04:37 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 Feb 2022 12:52:05 +0000 (12:52 +0000)
The function pci_find_capability() in t3_prep_adapter() can fail, so its
return value should be checked.

Fixes: 4d22de3e6cc4 ("Add support for the latest 1G/10G Chelsio adapter, T3")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb3/t3_hw.c

index da41eee2f25c7933ee1f72164508e0d23d49a313..a06003bfa04b9e72ec79074e9541c3fa3ec25ebd 100644 (file)
@@ -3613,6 +3613,8 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai,
            MAC_STATS_ACCUM_SECS : (MAC_STATS_ACCUM_SECS * 10);
        adapter->params.pci.vpd_cap_addr =
            pci_find_capability(adapter->pdev, PCI_CAP_ID_VPD);
+       if (!adapter->params.pci.vpd_cap_addr)
+               return -ENODEV;
        ret = get_vpd_params(adapter, &adapter->params.vpd);
        if (ret < 0)
                return ret;