Skip to content

Commit e9d8ea1

Browse files
committed
netfilter: ctnetlink: fix possible refcount leak in ctnetlink_create_conntrack()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2189550 Upstream Status: commit ac48939 commit ac48939 Author: Hangyu Hua <hbh25y@gmail.com> Date: Fri Feb 10 15:17:30 2023 +0800 netfilter: ctnetlink: fix possible refcount leak in ctnetlink_create_conntrack() nf_ct_put() needs to be called to put the refcount got by nf_conntrack_find_get() to avoid refcount leak when nf_conntrack_hash_check_insert() fails. Fixes: 7d367e0 ("netfilter: ctnetlink: fix soft lockup when netlink adds new entries (v2)") Signed-off-by: Hangyu Hua <hbh25y@gmail.com> Acked-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Florian Westphal <fwestpha@redhat.com>
1 parent f60201c commit e9d8ea1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/netfilter/nf_conntrack_netlink.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2380,12 +2380,15 @@ ctnetlink_create_conntrack(struct net *net,
23802380

23812381
err = nf_conntrack_hash_check_insert(ct);
23822382
if (err < 0)
2383-
goto err2;
2383+
goto err3;
23842384

23852385
rcu_read_unlock();
23862386

23872387
return ct;
23882388

2389+
err3:
2390+
if (ct->master)
2391+
nf_ct_put(ct->master);
23892392
err2:
23902393
rcu_read_unlock();
23912394
err1:

0 commit comments

Comments
 (0)