diff mbox series

[next] net: hns3: Fix uninitialized return from function

Message ID 20210210152644.137770-1-colin.king@canonical.com
State New
Headers show
Series [next] net: hns3: Fix uninitialized return from function | expand

Commit Message

Colin King Feb. 10, 2021, 3:26 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Currently function hns3_reset_notify_uninit_enet is returning
the contents of the uninitialized variable ret.  Fix this by
removing ret (since it is no longer used) and replace it with
a return of the literal value 0.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 64749c9c38a9 ("net: hns3: remove redundant return value of hns3_uninit_all_ring()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

kernel test robot Feb. 10, 2021, 9:44 p.m. UTC | #1
Hi Colin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.11-rc7 next-20210125]
[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/net-hns3-Fix-uninitialized-return-from-function/20210210-233553
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e0756cfc7d7cd08c98a53b6009c091a3f6a50be6
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/e51cd2716c8b5c2ba8daf480c7852c6b2feaac82
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Colin-King/net-hns3-Fix-uninitialized-return-from-function/20210210-233553
        git checkout e51cd2716c8b5c2ba8daf480c7852c6b2feaac82
        # 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 errors (new ones prefixed by >>):

   drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function 'hns3_reset_notify_uninit_enet':
>> drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:4684:2: error: 'ret' undeclared (first use in this function); did you mean 'net'?
    4684 |  ret = hns3_uninit_all_ring(priv);
         |  ^~~
         |  net
   drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:4684:2: note: each undeclared identifier is reported only once for each function it appears in

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for FRAME_POINTER
   Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
   Selected by
   - FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86


vim +4684 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4662  
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4663  static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4664  {
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4665  	struct net_device *netdev = handle->kinfo.netdev;
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4666  	struct hns3_nic_priv *priv = netdev_priv(netdev);
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4667  
1eeb3367897a3f drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2019-04-04  4668  	if (!test_and_clear_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
814da63c557726 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2018-11-07  4669  		netdev_warn(netdev, "already uninitialized\n");
814da63c557726 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2018-11-07  4670  		return 0;
814da63c557726 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2018-11-07  4671  	}
814da63c557726 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2018-11-07  4672  
08a100689d4baf drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Yonglong Liu   2020-01-04  4673  	hns3_free_rx_cpu_rmap(netdev);
08a100689d4baf drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Yonglong Liu   2020-01-04  4674  	hns3_nic_uninit_irq(priv);
f96315f2f17e7b drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2019-06-28  4675  	hns3_clear_all_ring(handle, true);
f96315f2f17e7b drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2019-06-28  4676  	hns3_reset_tx_queue(priv->ae_handle);
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4677  
e215278548f9ea drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2019-01-31  4678  	hns3_nic_uninit_vector_data(priv);
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4679  
e4fd75022c24eb drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2018-09-26  4680  	hns3_store_coal(priv);
e4fd75022c24eb drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2018-09-26  4681  
08a100689d4baf drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Yonglong Liu   2020-01-04  4682  	hns3_nic_dealloc_vector_data(priv);
862d969a3a4dcd drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2018-11-09  4683  
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02 @4684  	ret = hns3_uninit_all_ring(priv);
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4685  	if (ret)
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4686  		netdev_err(netdev, "uninit ring error\n");
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4687  
2c9dd668914bb9 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2019-01-18  4688  	hns3_put_ring_config(priv);
2c9dd668914bb9 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Huazhong Tan   2019-01-18  4689  
e51cd2716c8b5c drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        Colin Ian King 2021-02-10  4690  	return 0;
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4691  }
bb6b94a896d4dd drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c Lipeng         2017-11-02  4692  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Peng Li Feb. 18, 2021, 2:14 a.m. UTC | #2
在 2021/2/10 23:26, Colin King 写道:
> From: Colin Ian King <colin.king@canonical.com>

>

> Currently function hns3_reset_notify_uninit_enet is returning

> the contents of the uninitialized variable ret.  Fix this by

> removing ret (since it is no longer used) and replace it with

> a return of the literal value 0.



you can not remove "ret"  this way.

try to change  "int hns3_uninit_all_ring"  to "void 
hns3_uninit_all_ring" and fix related code is better.


>

> Addresses-Coverity: ("Uninitialized scalar variable")

> Fixes: 64749c9c38a9 ("net: hns3: remove redundant return value of hns3_uninit_all_ring()")

> Signed-off-by: Colin Ian King <colin.king@canonical.com>

> ---

>   drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +--

>   1 file changed, 1 insertion(+), 2 deletions(-)

>

> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

> index 9565b7999426..bf4302a5cf95 100644

> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

> @@ -4640,7 +4640,6 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)

>   {

>   	struct net_device *netdev = handle->kinfo.netdev;

>   	struct hns3_nic_priv *priv = netdev_priv(netdev);

> -	int ret;

>   

>   	if (!test_and_clear_bit(HNS3_NIC_STATE_INITED, &priv->state)) {

>   		netdev_warn(netdev, "already uninitialized\n");

> @@ -4662,7 +4661,7 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)

>   

>   	hns3_put_ring_config(priv);

>   

> -	return ret;

> +	return 0;

>   }

>   

>   static int hns3_reset_notify(struct hnae3_handle *handle,
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 9565b7999426..bf4302a5cf95 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -4640,7 +4640,6 @@  static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
 {
 	struct net_device *netdev = handle->kinfo.netdev;
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
-	int ret;
 
 	if (!test_and_clear_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
 		netdev_warn(netdev, "already uninitialized\n");
@@ -4662,7 +4661,7 @@  static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
 
 	hns3_put_ring_config(priv);
 
-	return ret;
+	return 0;
 }
 
 static int hns3_reset_notify(struct hnae3_handle *handle,