All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Jiri Pirko <jiri@resnulli.us>
Cc: Moshe Shemesh <moshe@nvidia.com>, netdev@vger.kernel.org
Subject: Re: [bug report] devlink: Move devlink dev reload code to dev
Date: Wed, 19 Nov 2025 21:15:52 +0300	[thread overview]
Message-ID: <aR4JWMyC7QHITJZp@stanley.mountain> (raw)
In-Reply-To: <35ekvmjyb4ty5vdkyspwirz4qoahotpow22zt4vkonqjmtqziz@yk6pwla34ayn>

On Wed, Nov 19, 2025 at 06:19:18PM +0100, Jiri Pirko wrote:
> Wed, Nov 19, 2025 at 09:55:58AM +0100, dan.carpenter@linaro.org wrote:
> >Hello Moshe Shemesh,
> >
> >Commit c6ed7d6ef929 ("devlink: Move devlink dev reload code to dev")
> >from Feb 2, 2023 (linux-next), leads to the following Smatch static
> >checker warning:
> >
> >	net/devlink/dev.c:408 devlink_netns_get()
> >	error: potential NULL/IS_ERR bug 'net'
> >
> >net/devlink/dev.c
> >    378 static struct net *devlink_netns_get(struct sk_buff *skb,
> >    379                                      struct genl_info *info)
> >    380 {
> >    381         struct nlattr *netns_pid_attr = info->attrs[DEVLINK_ATTR_NETNS_PID];
> >    382         struct nlattr *netns_fd_attr = info->attrs[DEVLINK_ATTR_NETNS_FD];
> >    383         struct nlattr *netns_id_attr = info->attrs[DEVLINK_ATTR_NETNS_ID];
> >    384         struct net *net;
> >    385 
> >    386         if (!!netns_pid_attr + !!netns_fd_attr + !!netns_id_attr > 1) {
> >    387                 NL_SET_ERR_MSG(info->extack, "multiple netns identifying attributes specified");
> >    388                 return ERR_PTR(-EINVAL);
> >    389         }
> >    390 
> >    391         if (netns_pid_attr) {
> >    392                 net = get_net_ns_by_pid(nla_get_u32(netns_pid_attr));
> >
> >Smatch thinks that the "net = get_net(nsproxy->net_ns);" could mean that
> >get_net_ns_by_pid() returns NULL.  I don't know if that's correct or not.
> >If someone could tell me, then it's easy for me to add a line
> >"get_net_ns_by_pid 0" to the smatch_data/db/kernel.delete.return_states
> >file but I'd prefer to be sure before I do that...
> 
> I don't see how get_net() can return NULL.
> 

It returns whatever you pass to it.  The ns_ref_inc() macro
has a NULL check built in so it accepts NULL pointers.

regards,
dan carpenter


  reply	other threads:[~2025-11-19 18:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19  8:55 [bug report] devlink: Move devlink dev reload code to dev Dan Carpenter
2025-11-19 17:19 ` Jiri Pirko
2025-11-19 18:15   ` Dan Carpenter [this message]
2025-11-20 12:10     ` Jiri Pirko
2025-11-20 12:35       ` Dan Carpenter

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=aR4JWMyC7QHITJZp@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=jiri@resnulli.us \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.