Skip to contentSkip to conversation

drivers/net/ethernet/huawei/hinic/hinic_port.c:459 hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev' (see line 453)

DISCUSSION kernel test robot 1 participant 1 message Sep 11, 2023

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Cai Huoqing <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   0bb80ecc33a8fb5a682236443c1e740d5c917d1d
commit: 2acf960e3be6177f437baade6d1883ebe4c641b2 net: hinic: Add support for configuration of rx-vlan-filter by ethtool
date:   10 months ago

:::::: branch date: 16 hours ago
:::::: commit date: 10 months ago
config: x86_64-randconfig-161-20230911 (https://download.01.org/0day-ci/archive/20230911/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230911/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/net/ethernet/huawei/hinic/hinic_port.c:459 hinic_set_vlan_fliter() warn: variable dereferenced before check 'hwdev' (see line 453)

vim +/hwdev +459 drivers/net/ethernet/huawei/hinic/hinic_port.c

aebd17b7685499 Xue Chaojing 2019-06-29  449  
2acf960e3be617 Cai Huoqing  2022-11-03  450  int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en)
2acf960e3be617 Cai Huoqing  2022-11-03  451  {
2acf960e3be617 Cai Huoqing  2022-11-03  452  	struct hinic_hwdev *hwdev = nic_dev->hwdev;
2acf960e3be617 Cai Huoqing  2022-11-03 @453  	struct hinic_hwif *hwif = hwdev->hwif;
2acf960e3be617 Cai Huoqing  2022-11-03  454  	struct pci_dev *pdev = hwif->pdev;
2acf960e3be617 Cai Huoqing  2022-11-03  455  	struct hinic_vlan_filter vlan_filter;
2acf960e3be617 Cai Huoqing  2022-11-03  456  	u16 out_size = sizeof(vlan_filter);
2acf960e3be617 Cai Huoqing  2022-11-03  457  	int err;
2acf960e3be617 Cai Huoqing  2022-11-03  458  
2acf960e3be617 Cai Huoqing  2022-11-03 @459  	if (!hwdev)
2acf960e3be617 Cai Huoqing  2022-11-03  460  		return -EINVAL;
2acf960e3be617 Cai Huoqing  2022-11-03  461  
2acf960e3be617 Cai Huoqing  2022-11-03  462  	vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
2acf960e3be617 Cai Huoqing  2022-11-03  463  	vlan_filter.enable = en;
2acf960e3be617 Cai Huoqing  2022-11-03  464  
2acf960e3be617 Cai Huoqing  2022-11-03  465  	err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_VLAN_FILTER,
2acf960e3be617 Cai Huoqing  2022-11-03  466  				 &vlan_filter, sizeof(vlan_filter),
2acf960e3be617 Cai Huoqing  2022-11-03  467  				 &vlan_filter, &out_size);
2acf960e3be617 Cai Huoqing  2022-11-03  468  	if (vlan_filter.status == HINIC_MGMT_CMD_UNSUPPORTED) {
2acf960e3be617 Cai Huoqing  2022-11-03  469  		err = HINIC_MGMT_CMD_UNSUPPORTED;
2acf960e3be617 Cai Huoqing  2022-11-03  470  	} else if ((err == HINIC_MBOX_VF_CMD_ERROR) &&
2acf960e3be617 Cai Huoqing  2022-11-03  471  			   HINIC_IS_VF(hwif)) {
2acf960e3be617 Cai Huoqing  2022-11-03  472  		err = HINIC_MGMT_CMD_UNSUPPORTED;
2acf960e3be617 Cai Huoqing  2022-11-03  473  	} else if (err || !out_size || vlan_filter.status) {
2acf960e3be617 Cai Huoqing  2022-11-03  474  		dev_err(&pdev->dev,
2acf960e3be617 Cai Huoqing  2022-11-03  475  			"Failed to set vlan fliter, err: %d, status: 0x%x, out size: 0x%x\n",
2acf960e3be617 Cai Huoqing  2022-11-03  476  			err, vlan_filter.status, out_size);
2acf960e3be617 Cai Huoqing  2022-11-03  477  		err = -EINVAL;
2acf960e3be617 Cai Huoqing  2022-11-03  478  	}
2acf960e3be617 Cai Huoqing  2022-11-03  479  
2acf960e3be617 Cai Huoqing  2022-11-03  480  	return err;
2acf960e3be617 Cai Huoqing  2022-11-03  481  }
2acf960e3be617 Cai Huoqing  2022-11-03  482  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki