Thread (26 messages) 26 messages, 5 authors, 2019-08-02

Re: [patch net-next 1/3] net: devlink: allow to change namespaces

From: David Miller <davem@davemloft.net>
Date: 2019-07-29 17:52:18

From: Jiri Pirko <jiri@resnulli.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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help