netfilter: xt_CT: fix refcnt leak on error path
authorGao Feng <fgao@ikuai8.com>
Fri, 14 Apr 2017 02:00:08 +0000 (10:00 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 24 Apr 2017 18:03:01 +0000 (20:03 +0200)
commit470acf55a021713869b9bcc967268ac90c8a0fac
tree09df3da328d3756c1f981458fbaad178b6539bd4
parent94836ecf1e7378b64d37624fbb81fe48fbd4c772
netfilter: xt_CT: fix refcnt leak on error path

There are two cases which causes refcnt leak.

1. When nf_ct_timeout_ext_add failed in xt_ct_set_timeout, it should
free the timeout refcnt.
Now goto the err_put_timeout error handler instead of going ahead.

2. When the time policy is not found, we should call module_put.
Otherwise, the related cthelper module cannot be removed anymore.
It is easy to reproduce by typing the following command:
  # iptables -t raw -A OUTPUT -p tcp -j CT --helper ftp --timeout xxx

Signed-off-by: Gao Feng <fgao@ikuai8.com>
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/xt_CT.c