Commit 284ca87c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Zheng Zengkai
Browse files

net: genl: fix error path memory leak in policy dumping

stable inclusion
from stable-v5.10.138
commit 83411c9f05d5a8b637293b3389eca3d378197c04
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60QFD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=83411c9f05d5a8b637293b3389eca3d378197c04



--------------------------------

commit 24980136 upstream.

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: default avatar <syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com>
Fixes: 50a896cf ("genetlink: properly support per-op policy dumping")
Link: https://lore.kernel.org/r/20220816161939.577583-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: default avatarWei Li <liwei391@huawei.com>
parent e6ae5811
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment