Mon, Jul 29, 2019 at 07:52:16PM CEST, da...@davemloft.net wrote:
>From: Jiri Pirko <j...@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) {
>       ...

I just copied the logic from the existing code. But sure :)


>
>> +
>> +    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.

It does not complain though. The function cannot be entered unless at
least one is. I'll check again.


>
>Thanks.

Reply via email to