Subject: Re: [PATCH net-next] ethtool: add netlink based get rxfh support

From: kernel test robot <[email-masked]>
Date: Fri, 4 Nov 2022 07:05:46 +0800

Hi Sudheer,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Sudheer-Mogilappagari/ethtool-add-netlink-based-get-rxfh-support/20221104-051829
patch link:    https://lore.kernel.org/r/20221103211419.2615321-1-sudheer.mogilappagari%40intel.com
patch subject: [PATCH net-next] ethtool: add netlink based get rxfh support
config: riscv-randconfig-r005-20221102
compiler: clang version 15.0.4 (https://github.com/llvm/llvm-project 5c68a1cb123161b54b72ce90e7975d95a8eaf2a4)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/0ac74264773782495c9a77b0696c676f3a406a3b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Sudheer-Mogilappagari/ethtool-add-netlink-based-get-rxfh-support/20221104-051829
        git checkout 0ac74264773782495c9a77b0696c676f3a406a3b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash net/ethtool/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email-masked]>

All warnings (new ones prefixed by >>):

>> net/ethtool/rxfh.c:65:6: warning: variable 'hkey_size' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (ops->get_rxfh_key_size)
               ^~~~~~~~~~~~~~~~~~~~~~
   net/ethtool/rxfh.c:69:29: note: uninitialized use occurs here
           total_size = indir_bytes + hkey_size;
                                      ^~~~~~~~~
   net/ethtool/rxfh.c:65:2: note: remove the 'if' if its condition is always true
           if (ops->get_rxfh_key_size)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/ethtool/rxfh.c:29:27: note: initialize the variable 'hkey_size' to silence this warning
           u32 indir_size, hkey_size, total_size, indir_bytes;
                                    ^
                                     = 0
>> net/ethtool/rxfh.c:63:6: warning: variable 'indir_size' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (ops->get_rxfh_indir_size)
               ^~~~~~~~~~~~~~~~~~~~~~~~
   net/ethtool/rxfh.c:68:16: note: uninitialized use occurs here
           indir_bytes = indir_size * sizeof(rxfh->rss_config[0]);
                         ^~~~~~~~~~
   net/ethtool/rxfh.c:63:2: note: remove the 'if' if its condition is always true
           if (ops->get_rxfh_indir_size)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/ethtool/rxfh.c:29:16: note: initialize the variable 'indir_size' to silence this warning
           u32 indir_size, hkey_size, total_size, indir_bytes;
                         ^
                          = 0
   2 warnings generated.

vim +65 net/ethtool/rxfh.c

    23	
    24	static int rxfh_prepare_data(const struct ethnl_req_info *req_base,
    25				     struct ethnl_reply_data *reply_base,
    26				     struct genl_info *info)
    27	{
    28		struct rxfh_reply_data *data = RXFH_REPDATA(reply_base);
    29		u32 indir_size, hkey_size, total_size, indir_bytes;
    30		struct net_device *dev = reply_base->dev;
    31		struct ethtool_rxfh *rxfh = &data->rxfh;
    32		struct ethnl_req_info req_info = {};
    33		struct nlattr **tb = info->attrs;
    34		const struct ethtool_ops *ops;
    35		bool mod = false;
    36		u8 dev_hfunc = 0;
    37		u8 *hkey = NULL;
    38		u8 *rss_config;
    39		int ret;
    40	
    41		ops = dev->ethtool_ops;
    42		if (!ops->get_rxfh)
    43			return -EOPNOTSUPP;
    44	
    45		ret = ethnl_parse_header_dev_get(&req_info,
    46						 tb[ETHTOOL_A_RXFH_HEADER],
    47						 genl_info_net(info), info->extack,
    48						 true);
    49		if (ret < 0)
    50			return ret;
    51	
    52		ethnl_update_u32(&rxfh->rss_context, tb[ETHTOOL_A_RXFH_RSS_CONTEXT],
    53				 &mod);
    54	
    55		ret = ethnl_ops_begin(dev);
    56		if (ret < 0)
    57			return ret;
    58	
    59		/* Some drivers don't handle rss_context */
    60		if (rxfh->rss_context && !ops->get_rxfh_context)
    61			return -EOPNOTSUPP;
    62	
  > 63		if (ops->get_rxfh_indir_size)
    64			indir_size = ops->get_rxfh_indir_size(dev);
  > 65		if (ops->get_rxfh_key_size)
    66			hkey_size = ops->get_rxfh_key_size(dev);
    67	
    68		indir_bytes = indir_size * sizeof(rxfh->rss_config[0]);
    69		total_size = indir_bytes + hkey_size;
    70		rss_config = kzalloc(total_size, GFP_USER);
    71		if (!rss_config)
    72			return -ENOMEM;
    73	
    74		if (indir_size) {
    75			data->rss_config = (u32 *)rss_config;
    76			rxfh->indir_size = indir_size;
    77		}
    78	
    79		if (hkey_size) {
    80			hkey = rss_config + indir_bytes;
    81			rxfh->key_size = hkey_size;
    82		}
    83	
    84		if (rxfh->rss_context)
    85			ret = ops->get_rxfh_context(dev, data->rss_config, hkey,
    86						    &dev_hfunc, rxfh->rss_context);
    87		else
    88			ret = ops->get_rxfh(dev, data->rss_config, hkey, &dev_hfunc);
    89	
    90		rxfh->hfunc = dev_hfunc;
    91	
    92		ethnl_ops_complete(dev);
    93		ethnl_parse_header_dev_put(&req_info);
    94		return ret;
    95	}
    96	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp