netfilter: fix memory leaks on netlink_dump_start error
authorFlorian Westphal <fw@strlen.de>
Tue, 31 Jul 2018 11:41:23 +0000 (13:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Sep 2018 07:45:28 +0000 (09:45 +0200)
commit58de2cef2b6834dce6d2c7014215739603d43eab
treeb53c0365d427decb5b636a01597a5b1102fe68d1
parente4f419133dfaa72f9830f258ca10527e3ab359a9
netfilter: fix memory leaks on netlink_dump_start error

[ Upstream commit 3e673b23b541b8e7f773b2d378d6eb99831741cd ]

Shaochun Chen points out we leak dumper filter state allocations
stored in dump_control->data in case there is an error before netlink sets
cb_running (after which ->done will be called at some point).

In order to fix this, add .start functions and move allocations there.

Same pattern as used in commit 90fd131afc565159c9e0ea742f082b337e10f8c6
("netfilter: nf_tables: move dumper state allocation into ->start").

Reported-by: shaochun chen <cscnull@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nfnetlink_acct.c