]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: genetlink: return the error code when attribute parsing fails.
authorPaolo Abeni <pabeni@redhat.com>
Fri, 21 Feb 2020 18:42:13 +0000 (19:42 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 23 Feb 2020 05:58:33 +0000 (21:58 -0800)
Currently if attribute parsing fails and the genl family
does not support parallel operation, the error code returned
by __nlmsg_parse() is discarded by genl_family_rcv_msg_attrs_parse().

Be sure to report the error for all genl families.

Fixes: 3693a880776e ("net: genetlink: push attrbuf allocation and parsing to a separate function")
Fixes: 45b975f3f467 ("net: genetlink: always allocate separate attrs for dumpit ops")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/genetlink.c

index 0522b2b1fd958ce17de51163df8505d2b754d988..9f357aa22b9452d17f5c391a159d263c4f3df552 100644 (file)
@@ -497,8 +497,9 @@ genl_family_rcv_msg_attrs_parse(const struct genl_family *family,
 
        err = __nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr,
                            family->policy, validate, extack);
-       if (err && parallel) {
-               kfree(attrbuf);
+       if (err) {
+               if (parallel)
+                       kfree(attrbuf);
                return ERR_PTR(err);
        }
        return attrbuf;