netfilter: x_tables: handle xt_register_template() returning an error value
authorLukas Bulwahn <lukas.bulwahn@gmail.com>
Mon, 23 Aug 2021 20:27:29 +0000 (22:27 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 25 Aug 2021 11:06:48 +0000 (13:06 +0200)
Commit fdacd57c79b7 ("netfilter: x_tables: never register tables by
default") introduces the function xt_register_template(), and in one case,
a call to that function was missing the error-case handling.

Handle when xt_register_template() returns an error value.

This was identified with the clang-analyzer's Dead-Store analysis.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/iptable_mangle.c

index b52a4c8..40417a3 100644 (file)
@@ -112,6 +112,8 @@ static int __init iptable_mangle_init(void)
 {
        int ret = xt_register_template(&packet_mangler,
                                       iptable_mangle_table_init);
+       if (ret < 0)
+               return ret;
 
        mangle_ops = xt_hook_ops_alloc(&packet_mangler, iptable_mangle_hook);
        if (IS_ERR(mangle_ops)) {