netfilter: nf_tables: add missing ->release_ops() in error path of newrule()
authorTaehee Yoo <ap420073@gmail.com>
Tue, 19 Mar 2019 04:22:41 +0000 (13:22 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 May 2019 17:41:26 +0000 (19:41 +0200)
commitc18731c2786c032ed618ebb4cbc04af71595e56c
tree2b318a5a42199d090ef2d73a9b0b541b129acaf3
parent5014aa93742293b4622b8d766ad0b08db2611f7f
netfilter: nf_tables: add missing ->release_ops() in error path of newrule()

[ Upstream commit b25a31bf0ca091aa8bdb9ab329b0226257568bbe ]

->release_ops() callback releases resources and this is used in error path.
If nf_tables_newrule() fails after ->select_ops(), it should release
resources. but it can not call ->destroy() because that should be called
after ->init().
At this point, ->release_ops() should be used for releasing resources.

Test commands:
   modprobe -rv xt_tcpudp
   iptables-nft -I INPUT -m tcp   <-- error command
   lsmod

Result:
   Module                  Size  Used by
   xt_tcpudp              20480  2      <-- it should be 0

Fixes: b8e204006340 ("netfilter: nft_compat: use .release_ops and remove list of extension")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
net/netfilter/nf_tables_api.c