]> git.baikalelectronics.ru Git - kernel.git/commit
net: genl: fix error path memory leak in policy dumping
authorJakub Kicinski <kuba@kernel.org>
Tue, 16 Aug 2022 16:19:39 +0000 (09:19 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 Aug 2022 17:20:48 +0000 (10:20 -0700)
commit493defce2ba738c70a0abe1b42f119ac8d8d136d
tree12f45371df138671e0ef5f3f6b0fdb3692b4dbe2
parent6fcc8f036be91dd8a4a49649ce490641820c15a7
net: genl: fix error path memory leak in policy dumping

If construction of the array of policies fails when recording
non-first policy we need to unwind.

netlink_policy_dump_add_policy() itself also needs fixing as
it currently gives up on error without recording the allocated
pointer in the pstate pointer.

Reported-by: syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com
Fixes: 95d4e7fd2965 ("genetlink: properly support per-op policy dumping")
Link: https://lore.kernel.org/r/20220816161939.577583-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/netlink/genetlink.c
net/netlink/policy.c