aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2018-11-22 10:05:01 +0000
committerDavid S. Miller <davem@davemloft.net>2018-11-23 17:22:02 -0800
commite159e592872edc0536f55ec242dbc5b70a593265 (patch)
tree506b7ee61c3e681b8633d3c386ac55f873d4007f /drivers
parentMerge branch 'smc-next' (diff)
downloadlinux-dev-e159e592872edc0536f55ec242dbc5b70a593265.tar.xz
linux-dev-e159e592872edc0536f55ec242dbc5b70a593265.zip
net: hinic: fix null pointer dereference on pointer hwdev
Pointer hwdev is being dereferenced when declaring hwif , however, later on hwdev is being null checked, hence we have dereference before null check error. Fix this by assigning hwif and pdef only once hwdev has been null checked. Detected by CoverityScan, CID#1485581 ("Dereference before null check") Fixes: 4a61abb100c8 ("net-next/hinic:add rx checksum offload for HiNIC") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_port.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c
index e9f76e904610..122c93597268 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_port.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c
@@ -414,14 +414,16 @@ int hinic_set_rx_csum_offload(struct hinic_dev *nic_dev, u32 en)
{
struct hinic_checksum_offload rx_csum_cfg = {0};
struct hinic_hwdev *hwdev = nic_dev->hwdev;
- struct hinic_hwif *hwif = hwdev->hwif;
- struct pci_dev *pdev = hwif->pdev;
+ struct hinic_hwif *hwif;
+ struct pci_dev *pdev;
u16 out_size;
int err;
if (!hwdev)
return -EINVAL;
+ hwif = hwdev->hwif;
+ pdev = hwif->pdev;
rx_csum_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
rx_csum_cfg.rx_csum_offload = en;