lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 23 Jul 2021 10:53:36 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Luo bin <luobin9@...wei.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org
Subject: [kbuild] drivers/net/ethernet/huawei/hinic/hinic_debugfs.c:92
 hinic_dbg_get_func_table() warn: returning -1 instead of -ENOMEM is sloppy

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git  master
head:   8baef6386baaefb776bdd09b5c7630cf057c51c6
commit: 5215e16244ee5889cc6135381acdbf4cbcb7905a hinic: add support to query function table
config: x86_64-randconfig-m001-20210723 (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
drivers/net/ethernet/huawei/hinic/hinic_debugfs.c:92 hinic_dbg_get_func_table() warn: returning -1 instead of -ENOMEM is sloppy

vim +92 drivers/net/ethernet/huawei/hinic/hinic_debugfs.c

5215e16244ee58 Luo bin 2020-08-28   83  static int hinic_dbg_get_func_table(struct hinic_dev *nic_dev, int idx)
5215e16244ee58 Luo bin 2020-08-28   84  {
5215e16244ee58 Luo bin 2020-08-28   85  	struct tag_sml_funcfg_tbl *funcfg_table_elem;
5215e16244ee58 Luo bin 2020-08-28   86  	struct hinic_cmd_lt_rd *read_data;
5215e16244ee58 Luo bin 2020-08-28   87  	u16 out_size = sizeof(*read_data);
5215e16244ee58 Luo bin 2020-08-28   88  	int err;
5215e16244ee58 Luo bin 2020-08-28   89  
5215e16244ee58 Luo bin 2020-08-28   90  	read_data = kzalloc(sizeof(*read_data), GFP_KERNEL);
5215e16244ee58 Luo bin 2020-08-28   91  	if (!read_data)
5215e16244ee58 Luo bin 2020-08-28  @92  		return ~0;
                                                        ^^^^^^^^^
return -ENOMEM;

5215e16244ee58 Luo bin 2020-08-28   93  
5215e16244ee58 Luo bin 2020-08-28   94  	read_data->node = TBL_ID_FUNC_CFG_SM_NODE;
5215e16244ee58 Luo bin 2020-08-28   95  	read_data->inst = TBL_ID_FUNC_CFG_SM_INST;
5215e16244ee58 Luo bin 2020-08-28   96  	read_data->entry_size = HINIC_FUNCTION_CONFIGURE_TABLE_SIZE;
5215e16244ee58 Luo bin 2020-08-28   97  	read_data->lt_index = HINIC_HWIF_FUNC_IDX(nic_dev->hwdev->hwif);
5215e16244ee58 Luo bin 2020-08-28   98  	read_data->len = HINIC_FUNCTION_CONFIGURE_TABLE_SIZE;
5215e16244ee58 Luo bin 2020-08-28   99  
5215e16244ee58 Luo bin 2020-08-28  100  	err = hinic_port_msg_cmd(nic_dev->hwdev, HINIC_PORT_CMD_RD_LINE_TBL, read_data,
5215e16244ee58 Luo bin 2020-08-28  101  				 sizeof(*read_data), read_data, &out_size);
5215e16244ee58 Luo bin 2020-08-28  102  	if (err || out_size != sizeof(*read_data) || read_data->status) {
5215e16244ee58 Luo bin 2020-08-28  103  		netif_err(nic_dev, drv, nic_dev->netdev,
5215e16244ee58 Luo bin 2020-08-28  104  			  "Failed to get func table, err: %d, status: 0x%x, out size: 0x%x\n",
5215e16244ee58 Luo bin 2020-08-28  105  			  err, read_data->status, out_size);
5215e16244ee58 Luo bin 2020-08-28  106  		kfree(read_data);
5215e16244ee58 Luo bin 2020-08-28  107  		return ~0;

return -EIO;?

5215e16244ee58 Luo bin 2020-08-28  108  	}
5215e16244ee58 Luo bin 2020-08-28  109  
5215e16244ee58 Luo bin 2020-08-28  110  	funcfg_table_elem = (struct tag_sml_funcfg_tbl *)read_data->data;
5215e16244ee58 Luo bin 2020-08-28  111  
5215e16244ee58 Luo bin 2020-08-28  112  	switch (idx) {
5215e16244ee58 Luo bin 2020-08-28  113  	case VALID:
5215e16244ee58 Luo bin 2020-08-28  114  		return funcfg_table_elem->dw0.bs.valid;
5215e16244ee58 Luo bin 2020-08-28  115  	case RX_MODE:
5215e16244ee58 Luo bin 2020-08-28  116  		return funcfg_table_elem->dw0.bs.nic_rx_mode;
5215e16244ee58 Luo bin 2020-08-28  117  	case MTU:
5215e16244ee58 Luo bin 2020-08-28  118  		return funcfg_table_elem->dw1.bs.mtu;
5215e16244ee58 Luo bin 2020-08-28  119  	case RQ_DEPTH:
5215e16244ee58 Luo bin 2020-08-28  120  		return funcfg_table_elem->dw13.bs.cfg_rq_depth;
5215e16244ee58 Luo bin 2020-08-28  121  	case QUEUE_NUM:
5215e16244ee58 Luo bin 2020-08-28  122  		return funcfg_table_elem->dw13.bs.cfg_q_num;
5215e16244ee58 Luo bin 2020-08-28  123  	}
5215e16244ee58 Luo bin 2020-08-28  124  
5215e16244ee58 Luo bin 2020-08-28  125  	kfree(read_data);
5215e16244ee58 Luo bin 2020-08-28  126  
5215e16244ee58 Luo bin 2020-08-28  127  	return ~0;

return -EINVAL;

5215e16244ee58 Luo bin 2020-08-28  128  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org 

_______________________________________________
kbuild mailing list -- kbuild@...ts.01.org
To unsubscribe send an email to kbuild-leave@...ts.01.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ