genetlink: clean up family attributes allocations
authorCong Wang <xiyou.wangcong@gmail.com>
Fri, 12 Jun 2020 07:16:55 +0000 (00:16 -0700)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:35:53 +0000 (15:35 -0400)
commite3c568840445bc4fcec7dd194b564b0d1dc4c50c
treeec53173f462d05c0063efe703f61ef0ae7275cde
parentccc3001d46939271e44cdd1b09baf8e03471ae6a
genetlink: clean up family attributes allocations

[ Upstream commit b65ce380b754e77fbfdcfc83fd6e29c8ceedf431 ]

genl_family_rcv_msg_attrs_parse() and genl_family_rcv_msg_attrs_free()
take a boolean parameter to determine whether allocate/free the family
attrs. This is unnecessary as we can just check family->parallel_ops.
More importantly, callers would not need to worry about pairing these
parameters correctly after this patch.

And this fixes a memory leak, as after commit c36f05559104
("genetlink: fix memory leaks in genl_family_rcv_msg_dumpit()")
we call genl_family_rcv_msg_attrs_parse() for both parallel and
non-parallel cases.

Fixes: c36f05559104 ("genetlink: fix memory leaks in genl_family_rcv_msg_dumpit()")
Reported-by: Ido Schimmel <idosch@idosch.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Tested-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netlink/genetlink.c