Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91ec701a authored by Pan Bian's avatar Pan Bian Committed by David S. Miller
Browse files

qlcnic: fix unchecked return value



Function pci_find_ext_capability() may return 0, which is an invalid
address. In function qlcnic_sriov_virtid_fn(), its return value is used
without validation. This may result in invalid memory access bugs. This
patch fixes the bug.

Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2a39e7aa
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -128,6 +128,8 @@ static int qlcnic_sriov_virtid_fn(struct qlcnic_adapter *adapter, int vf_id)
		return 0;
		return 0;


	pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV);
	pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SRIOV);
	if (!pos)
		return 0;
	pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &offset);
	pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &offset);
	pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &stride);
	pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &stride);