public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guillaume Nault <gnault@redhat.com>
To: Dan Carpenter <error27@gmail.com>
Cc: oe-kbuild@lists.linux.dev, Cong Wang <cong.wang@bytedance.com>,
	lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: net/l2tp/l2tp_core.c:1481 l2tp_tunnel_register() warn: missing error code 'ret'
Date: Mon, 13 Feb 2023 12:15:35 +0100	[thread overview]
Message-ID: <Y+ob1xnM09kMlbRp@debian> (raw)
In-Reply-To: <Y+nLBPj70/03q8Do@kadam>

On Mon, Feb 13, 2023 at 08:30:44AM +0300, Dan Carpenter wrote:
> On Fri, Feb 03, 2023 at 01:21:48PM +0100, Guillaume Nault wrote:
> > On Fri, Feb 03, 2023 at 11:56:01AM +0300, Dan Carpenter wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   66a87fff1a87c260452f5a57123891ca5258c449
> > > commit: c4d48a58f32c5972174a1d01c33b296fe378cce0 l2tp: convert l2tp_tunnel_list to idr
> > > config: powerpc-randconfig-m031-20230202 (https://download.01.org/0day-ci/archive/20230203/202302031144.yY6UaRcD-lkp@intel.com/config)
> > > compiler: powerpc-linux-gcc (GCC) 12.1.0
> > > 
> > > If you fix the issue, kindly add following tag where applicable
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Reported-by: Dan Carpenter <error27@gmail.com>
> > > 
> > > smatch warnings:
> > > net/l2tp/l2tp_core.c:1481 l2tp_tunnel_register() warn: missing error code 'ret'
> > > 
> > > vim +/ret +1481 net/l2tp/l2tp_core.c
> > > 
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1456  int l2tp_tunnel_register(struct l2tp_tunnel *tunnel, struct net *net,
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1457  			 struct l2tp_tunnel_cfg *cfg)
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1458  {
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1459  	struct l2tp_net *pn = l2tp_pernet(net);
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1460  	u32 tunnel_id = tunnel->tunnel_id;
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1461  	struct socket *sock;
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1462  	struct sock *sk;
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1463  	int ret;
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1464  
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1465  	spin_lock_bh(&pn->l2tp_tunnel_idr_lock);
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1466  	ret = idr_alloc_u32(&pn->l2tp_tunnel_idr, NULL, &tunnel_id, tunnel_id,
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1467  			    GFP_ATOMIC);
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1468  	spin_unlock_bh(&pn->l2tp_tunnel_idr_lock);
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1469  	if (ret)
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1470  		return ret == -ENOSPC ? -EEXIST : ret;
> > > c4d48a58f32c59 Cong Wang       2023-01-13  1471  
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1472  	if (tunnel->fd < 0) {
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1473  		ret = l2tp_tunnel_sock_create(net, tunnel->tunnel_id,
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1474  					      tunnel->peer_tunnel_id, cfg,
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1475  					      &sock);
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1476  		if (ret < 0)
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1477  			goto err;
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1478  	} else {
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1479  		sock = sockfd_lookup(tunnel->fd, &ret);
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10  1480  		if (!sock)
> > > 6b9f34239b00e6 Guillaume Nault 2018-04-10 @1481  			goto err;
> > >                                                                         ^^^^^^^^^
> > > I don't know why this is showing up as a 3 week old warning when it
> > > looks like the code is from 2018...  Anyway, should this be an error
> > > path or a success path?
> > 
> > This is an error path.
> > But I don't understand this warning. Does it complain that 'ret' isn't
> > initialised before the 'goto err;' jump? (this is done by
> > sockfd_lookup() in case of error).
> 
> Or sorry, I didn't see the &ret.

No problem.

> Yes, Smatch thinks "ret" is zero here.
> The kbuild-bot can't use the cross function database (building the DB
> is too slow to scale).  So that's why the warning is printed.

Okay, thanks for the explanations.

> regards,
> dan carpenter
> 


      reply	other threads:[~2023-02-13 11:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03  8:56 net/l2tp/l2tp_core.c:1481 l2tp_tunnel_register() warn: missing error code 'ret' Dan Carpenter
2023-02-03 12:21 ` Guillaume Nault
2023-02-13  5:30   ` Dan Carpenter
2023-02-13 11:15     ` Guillaume Nault [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y+ob1xnM09kMlbRp@debian \
    --to=gnault@redhat.com \
    --cc=cong.wang@bytedance.com \
    --cc=error27@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox