[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190729.105216.2073541569967891866.davem@davemloft.net>
Date: Mon, 29 Jul 2019 10:52:16 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: jiri@...nulli.us
Cc: netdev@...r.kernel.org, jakub.kicinski@...ronome.com,
sthemmin@...rosoft.com, dsahern@...il.com, mlxsw@...lanox.com
Subject: Re: [patch net-next 1/3] net: devlink: allow to change namespaces
From: Jiri Pirko <jiri@...nulli.us>
Date: Sat, 27 Jul 2019 11:44:57 +0200
> + if ((netns_pid_attr && (netns_fd_attr || netns_id_attr)) ||
> + (netns_fd_attr && (netns_pid_attr || netns_id_attr)) ||
> + (netns_id_attr && (netns_pid_attr || netns_fd_attr))) {
> + NL_SET_ERR_MSG(info->extack, "multiple netns identifying attributes specified");
> + return ERR_PTR(-EINVAL);
> + }
How about:
if (!!a + !!b + !!c > 1) {
...
> +
> + if (netns_pid_attr) {
> + net = get_net_ns_by_pid(nla_get_u32(netns_pid_attr));
> + } else if (netns_fd_attr) {
> + net = get_net_ns_by_fd(nla_get_u32(netns_fd_attr));
> + } else if (netns_id_attr) {
> + net = get_net_ns_by_id(sock_net(skb->sk),
> + nla_get_u32(netns_id_attr));
> + if (!net)
> + net = ERR_PTR(-EINVAL);
> + }
> + if (IS_ERR(net)) {
I think this is going to be one of those cases where a compiler won't be able
to prove that 'net' is guaranteed to be initialized at this spot. Please
rearrange this code somehow so that is unlikely to happen.
Thanks.
Powered by blists - more mailing lists