Skip to contentSkip to conversation

netfilter: x_tables: handle xt_register_template() returning an error value

PATCH Applied Lukas Bulwahn 3 participants 3 messages Aug 23, 2021 – Aug 25, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: x_tables: handle xt_register_template() returning an error value

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.

---
 net/ipv4/netfilter/iptable_mangle.c | 2 ++
 1 file changed, 2 insertions(+)
net/ipv4/netfilter/iptable_mangle.c +2 -0
index b52a4c8a14fc..40417a3f930b 100644
@@ -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)) {
Signature · 1 line
2.26.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Lukas Bulwahn

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.

Fixes fdacd57c79b7 ("netfilter: x_tables: never register tables by > default")

This needs to go to nf-next.

maintainer Applied
#2 lore raw
In reply to Lukas Bulwahn
Quoted 7 lines · Lukas Bulwahn

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.

Applied, thanks.