kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iavf: remove redundant null check on key
@ 2021-07-02 11:27 Colin King
  2021-07-02 18:43 ` kernel test robot
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2021-07-02 11:27 UTC (permalink / raw)
  To: Jesse Brandeburg, Tony Nguyen, Jakub Kicinski, intel-wired-lan, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The null check on pointer key has already been performed at the
start of the function and this leads to a return of -EOPNOTSUPP.
The second null check on key is therefore always false, it is
redundant and can be removed.

Addresses-Coverity: ("Logically dead code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index af43fbd8cb75..70193d8d54ed 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -1873,8 +1873,7 @@ static int iavf_set_rxfh(struct net_device *netdev, const u32 *indir,
 	if (!indir)
 		return 0;
 
-	if (key)
-		memcpy(adapter->rss_key, key, adapter->rss_key_size);
+	memcpy(adapter->rss_key, key, adapter->rss_key_size);
 
 	/* Each 32 bits pointed by 'indir' is stored with a lut entry */
 	for (i = 0; i < adapter->rss_lut_size; i++)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iavf: remove redundant null check on key
  2021-07-02 11:27 [PATCH] iavf: remove redundant null check on key Colin King
@ 2021-07-02 18:43 ` kernel test robot
  2021-07-03  9:49   ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2021-07-02 18:43 UTC (permalink / raw)
  To: Colin King, Jesse Brandeburg, Tony Nguyen, Jakub Kicinski,
	intel-wired-lan, netdev
  Cc: kbuild-all, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 7086 bytes --]

Hi Colin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tnguy-next-queue/dev-queue]
[also build test WARNING on v5.13 next-20210701]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Colin-King/iavf-remove-redundant-null-check-on-key/20210702-192826
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
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
        # https://github.com/0day-ci/linux/commit/59ac04f9a577d107d282cd2c5ef80272a7ad40f7
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Colin-King/iavf-remove-redundant-null-check-on-key/20210702-192826
        git checkout 59ac04f9a577d107d282cd2c5ef80272a7ad40f7
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/intel/iavf/iavf_ethtool.c: In function 'iavf_set_rxfh':
>> drivers/net/ethernet/intel/iavf/iavf_ethtool.c:1912:2: warning: argument 2 null where non-null expected [-Wnonnull]
    1912 |  memcpy(adapter->rss_key, key, adapter->rss_key_size);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/string.h:21,
                    from include/linux/bitmap.h:10,
                    from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/spinlock.h:59,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:16,
                    from drivers/net/ethernet/intel/iavf/iavf.h:7,
                    from drivers/net/ethernet/intel/iavf/iavf_ethtool.c:5:
   arch/ia64/include/asm/string.h:19:14: note: in a call to function 'memcpy' declared here
      19 | extern void *memcpy (void *, const void *, __kernel_size_t);
         |              ^~~~~~


vim +1912 drivers/net/ethernet/intel/iavf/iavf_ethtool.c

4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1888  
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1889  /**
129cf89e585676 drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg 2018-09-14  1890   * iavf_set_rxfh - set the rx flow hash indirection table
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1891   * @netdev: network interface device structure
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1892   * @indir: indirection table
2cda3f3be5c2f6 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch Williams   2014-11-11  1893   * @key: hash key
f5254429e1756a drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Jacob Keller     2018-04-20  1894   * @hfunc: hash function to use
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1895   *
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1896   * Returns -EINVAL if the table specifies an inavlid queue id, otherwise
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1897   * returns 0 after programming the table.
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1898   **/
129cf89e585676 drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg 2018-09-14  1899  static int iavf_set_rxfh(struct net_device *netdev, const u32 *indir,
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1900  			 const u8 *key, const u8 hfunc)
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1901  {
129cf89e585676 drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg 2018-09-14  1902  	struct iavf_adapter *adapter = netdev_priv(netdev);
2c86ac3c70794f drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Helin Zhang      2015-10-27  1903  	u16 i;
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1904  
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1905  	/* We do not allow change in unsupported parameters */
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1906  	if (key ||
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1907  	    (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1908  		return -EOPNOTSUPP;
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1909  	if (!indir)
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1910  		return 0;
892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1911  
43a3d9ba34c9ca drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch Williams   2016-04-12 @1912  	memcpy(adapter->rss_key, key, adapter->rss_key_size);
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1913  
2c86ac3c70794f drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Helin Zhang      2015-10-27  1914  	/* Each 32 bits pointed by 'indir' is stored with a lut entry */
43a3d9ba34c9ca drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch Williams   2016-04-12  1915  	for (i = 0; i < adapter->rss_lut_size; i++)
43a3d9ba34c9ca drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch Williams   2016-04-12  1916  		adapter->rss_lut[i] = (u8)(indir[i]);
2c86ac3c70794f drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Helin Zhang      2015-10-27  1917  
129cf89e585676 drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg 2018-09-14  1918  	return iavf_config_rss(adapter);
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1919  }
4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1920  

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 64298 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iavf: remove redundant null check on key
  2021-07-02 18:43 ` kernel test robot
@ 2021-07-03  9:49   ` Dan Carpenter
  2021-07-07 22:59     ` Nguyen, Anthony L
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2021-07-03  9:49 UTC (permalink / raw)
  To: kernel test robot
  Cc: Colin King, Jesse Brandeburg, Tony Nguyen, Jakub Kicinski,
	intel-wired-lan, netdev, kbuild-all, kernel-janitors,
	linux-kernel

On Sat, Jul 03, 2021 at 02:43:46AM +0800, kernel test robot wrote:
> 129cf89e585676 drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg 2018-09-14  1899  static int iavf_set_rxfh(struct net_device *netdev, const u32 *indir,
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1900  			 const u8 *key, const u8 hfunc)
> 4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1901  {
> 129cf89e585676 drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg 2018-09-14  1902  	struct iavf_adapter *adapter = netdev_priv(netdev);
> 2c86ac3c70794f drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Helin Zhang      2015-10-27  1903  	u16 i;
> 4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch A Williams 2014-04-01  1904  
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1905  	/* We do not allow change in unsupported parameters */
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1906  	if (key ||
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1907  	    (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1908  		return -EOPNOTSUPP;
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1909  	if (!indir)
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1910  		return 0;
> 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Eyal Perry       2014-12-02  1911  
> 43a3d9ba34c9ca drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c Mitch Williams   2016-04-12 @1912  	memcpy(adapter->rss_key, key, adapter->rss_key_size);

Heh...  There have been a bunch of patches modifying the behavior if
"key" is non-NULL and no one noticed that it's actually impossible.

:P

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iavf: remove redundant null check on key
  2021-07-03  9:49   ` Dan Carpenter
@ 2021-07-07 22:59     ` Nguyen, Anthony L
  0 siblings, 0 replies; 4+ messages in thread
From: Nguyen, Anthony L @ 2021-07-07 22:59 UTC (permalink / raw)
  To: dan.carpenter, lkp
  Cc: kernel-janitors, linux-kernel, kbuild-all, kuba, netdev,
	colin.king, Brandeburg, Jesse, intel-wired-lan

On Sat, 2021-07-03 at 12:49 +0300, Dan Carpenter wrote:
> On Sat, Jul 03, 2021 at 02:43:46AM +0800, kernel test robot wrote:
> > 129cf89e585676
> > drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg
> > 2018-09-14  1899  static int iavf_set_rxfh(struct net_device
> > *netdev, const u32 *indir,
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1900  			 const u8 *key,
> > const u8 hfunc)
> > 4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Mitch A Williams 2014-04-01  1901  {
> > 129cf89e585676
> > drivers/net/ethernet/intel/iavf/i40evf_ethtool.c   Jesse Brandeburg
> > 2018-09-14  1902  	struct iavf_adapter *adapter =
> > netdev_priv(netdev);
> > 2c86ac3c70794f drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Helin Zhang      2015-10-27  1903  	u16 i;
> > 4e9dc31f696ae8 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Mitch A Williams 2014-04-01  1904  
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1905  	/* We do not allow change in
> > unsupported parameters */
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1906  	if (key ||
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1907  	    (hfunc !=
> > ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1908  		return -EOPNOTSUPP;
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1909  	if (!indir)
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1910  		return 0;
> > 892311f66f2411 drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Eyal Perry       2014-12-02  1911  
> > 43a3d9ba34c9ca drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
> > Mitch Williams   2016-04-12 @1912  	memcpy(adapter->rss_key, key,
> > adapter->rss_key_size);
> 
> Heh...  There have been a bunch of patches modifying the behavior if
> "key" is non-NULL and no one noticed that it's actually impossible.

We are capable of supporting a key change. We're working on a patch to
resolve the check and allow the key to be changed.

- Tony

> :P
> 
> regards,
> dan carpenter
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-07 22:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 11:27 [PATCH] iavf: remove redundant null check on key Colin King
2021-07-02 18:43 ` kernel test robot
2021-07-03  9:49   ` Dan Carpenter
2021-07-07 22:59     ` Nguyen, Anthony L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).