public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment
@ 2026-04-03  8:44 Yue Haibing
  2026-04-06 14:35 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yue Haibing @ 2026-04-03  8:44 UTC (permalink / raw)
  To: davem, dsahern, edumazet, kuba, pabeni, horms, yuehaibing
  Cc: netdev, linux-kernel

The variable ret is initialized to 0 when it is defined
and is not modified before copy_to_user().

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
---
 net/ipv6/sit.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index ef2e5111fb3a..09c0a01d44f4 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -359,7 +359,6 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u
 	rcu_read_unlock();
 
 	len = sizeof(*kp) * c;
-	ret = 0;
 	if ((len && copy_to_user(a + 1, kp, len)) || put_user(len, &a->datalen))
 		ret = -EFAULT;
 
-- 
2.34.1


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

* Re: [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment
  2026-04-03  8:44 [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment Yue Haibing
@ 2026-04-06 14:35 ` Simon Horman
  2026-04-07  1:43 ` Jakub Kicinski
  2026-04-30  0:49 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2026-04-06 14:35 UTC (permalink / raw)
  To: Yue Haibing; +Cc: davem, dsahern, edumazet, kuba, pabeni, netdev, linux-kernel

On Fri, Apr 03, 2026 at 04:44:02PM +0800, Yue Haibing wrote:
> The variable ret is initialized to 0 when it is defined
> and is not modified before copy_to_user().
> 
> Signed-off-by: Yue Haibing <yuehaibing@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment
  2026-04-03  8:44 [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment Yue Haibing
  2026-04-06 14:35 ` Simon Horman
@ 2026-04-07  1:43 ` Jakub Kicinski
  2026-04-08  1:26   ` Yue Haibing
  2026-04-30  0:49 ` kernel test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2026-04-07  1:43 UTC (permalink / raw)
  To: Yue Haibing; +Cc: davem, dsahern, edumazet, pabeni, horms, netdev, linux-kernel

On Fri, 3 Apr 2026 16:44:02 +0800 Yue Haibing wrote:
> The variable ret is initialized to 0 when it is defined
> and is not modified before copy_to_user().

Makes more sense to remove the init during definition IMO.

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

* Re: [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment
  2026-04-07  1:43 ` Jakub Kicinski
@ 2026-04-08  1:26   ` Yue Haibing
  0 siblings, 0 replies; 5+ messages in thread
From: Yue Haibing @ 2026-04-08  1:26 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, dsahern, edumazet, pabeni, horms, netdev, linux-kernel

On 2026/4/7 9:43, Jakub Kicinski wrote:
> On Fri, 3 Apr 2026 16:44:02 +0800 Yue Haibing wrote:
>> The variable ret is initialized to 0 when it is defined
>> and is not modified before copy_to_user().
> 
> Makes more sense to remove the init during definition IMO.

OK,will do this in v2


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

* Re: [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment
  2026-04-03  8:44 [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment Yue Haibing
  2026-04-06 14:35 ` Simon Horman
  2026-04-07  1:43 ` Jakub Kicinski
@ 2026-04-30  0:49 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-04-30  0:49 UTC (permalink / raw)
  To: Yue Haibing, davem, dsahern, edumazet, kuba, pabeni, horms
  Cc: llvm, oe-kbuild-all, netdev, linux-kernel

Hi Yue,

kernel test robot noticed the following build warnings:

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

url:    https://github.com/intel-lab-lkp/linux/commits/Yue-Haibing/ipv6-sit-remove-redundant-ret-0-assignment/20260425-024700
base:   net-next/main
patch link:    https://lore.kernel.org/r/20260403084402.4105936-1-yuehaibing%40huawei.com
patch subject: [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20260430/202604300826.7OKegoUR-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260430/202604300826.7OKegoUR-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604300826.7OKegoUR-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/ipv6/sit.c:362:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     362 |         if ((len && copy_to_user(a + 1, kp, len)) || put_user(len, &a->datalen))
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/ipv6/sit.c:367:9: note: uninitialized use occurs here
     367 |         return ret;
         |                ^~~
   net/ipv6/sit.c:362:2: note: remove the 'if' if its condition is always true
     362 |         if ((len && copy_to_user(a + 1, kp, len)) || put_user(len, &a->datalen))
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     363 |                 ret = -EFAULT;
   net/ipv6/sit.c:312:9: note: initialize the variable 'ret' to silence this warning
     312 |         int ret;
         |                ^
         |                 = 0
   1 warning generated.


vim +362 net/ipv6/sit.c

fadf6bf0606913 Templin, Fred L   2008-03-11  305  
3e7a1c7c561ed8 Arnd Bergmann     2021-07-27  306  static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __user *a)
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  307  {
fd5d687b76b325 Christoph Hellwig 2020-05-19  308  	struct ip_tunnel *t = netdev_priv(dev);
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  309  	struct ip_tunnel_prl kprl, *kp;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  310  	struct ip_tunnel_prl_entry *prl;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  311  	unsigned int cmax, c = 0, ca, len;
3c6132ccc58e8a Yue Haibing       2026-04-08  312  	int ret;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  313  
fd5d687b76b325 Christoph Hellwig 2020-05-19  314  	if (dev == dev_to_sit_net(dev)->fb_tunnel_dev)
fd5d687b76b325 Christoph Hellwig 2020-05-19  315  		return -EINVAL;
fd5d687b76b325 Christoph Hellwig 2020-05-19  316  
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  317  	if (copy_from_user(&kprl, a, sizeof(kprl)))
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  318  		return -EFAULT;
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  319  	cmax = kprl.datalen / sizeof(kprl);
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  320  	if (cmax > 1 && kprl.addr != htonl(INADDR_ANY))
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  321  		cmax = 1;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  322  
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  323  	/* For simple GET or for root users,
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  324  	 * we try harder to allocate.
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  325  	 */
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  326  	kp = (cmax <= 1 || capable(CAP_NET_ADMIN)) ?
69050f8d6d075d Kees Cook         2026-02-20  327  		kzalloc_objs(*kp, cmax, GFP_KERNEL_ACCOUNT | __GFP_NOWARN) :
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  328  		NULL;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  329  
284fda1eff8a8b kernel test robot 2021-03-27  330  	ca = min(t->prl_count, cmax);
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  331  
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  332  	if (!kp) {
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  333  		/* We don't try hard to allocate much memory for
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  334  		 * non-root users.
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  335  		 * For root users, retry allocating enough memory for
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  336  		 * the answer.
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  337  		 */
69050f8d6d075d Kees Cook         2026-02-20  338  		kp = kzalloc_objs(*kp, ca,
69050f8d6d075d Kees Cook         2026-02-20  339  				  GFP_ATOMIC | __GFP_ACCOUNT | __GFP_NOWARN);
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  340  		if (!kp) {
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  341  			ret = -ENOMEM;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  342  			goto out;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  343  		}
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  344  	}
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  345  
adabdd8f6acabc katrinzhou        2022-06-28  346  	rcu_read_lock();
ef9a9d1183b36f Eric Dumazet      2009-10-23  347  	for_each_prl_rcu(t->prl) {
298bf12ddb2584 Sascha Hlusiak    2009-09-29  348  		if (c >= cmax)
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  349  			break;
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  350  		if (kprl.addr != htonl(INADDR_ANY) && prl->addr != kprl.addr)
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  351  			continue;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  352  		kp[c].addr = prl->addr;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  353  		kp[c].flags = prl->flags;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  354  		c++;
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  355  		if (kprl.addr != htonl(INADDR_ANY))
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  356  			break;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  357  	}
adabdd8f6acabc katrinzhou        2022-06-28  358  
ef9a9d1183b36f Eric Dumazet      2009-10-23  359  	rcu_read_unlock();
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  360  
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  361  	len = sizeof(*kp) * c;
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16 @362  	if ((len && copy_to_user(a + 1, kp, len)) || put_user(len, &a->datalen))
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  363  		ret = -EFAULT;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  364  
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  365  	kfree(kp);
adabdd8f6acabc katrinzhou        2022-06-28  366  out:
2b4743bd6be9fe YOSHIFUJI Hideaki 2008-06-16  367  	return ret;
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  368  }
300aaeeaab5f44 YOSHIFUJI Hideaki 2008-03-24  369  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2026-04-30  0:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03  8:44 [PATCH net-next] ipv6: sit: remove redundant ret = 0 assignment Yue Haibing
2026-04-06 14:35 ` Simon Horman
2026-04-07  1:43 ` Jakub Kicinski
2026-04-08  1:26   ` Yue Haibing
2026-04-30  0:49 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox