Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: genetlink: return the error code when attribute parsing fails.

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: c10e6cf85e7d ("net: genetlink: push attrbuf allocation and parsing to a separate function")
Fixes: ab5b526da048 ("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>

authored by

Paolo Abeni and committed by
David S. Miller
39f3b41a 3e72dfdf

+3 -2
+3 -2
net/netlink/genetlink.c
··· 497 497 498 498 err = __nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr, 499 499 family->policy, validate, extack); 500 - if (err && parallel) { 501 - kfree(attrbuf); 500 + if (err) { 501 + if (parallel) 502 + kfree(attrbuf); 502 503 return ERR_PTR(err); 503 504 } 504 505 return attrbuf;