diff mbox series

netfilter: synproxy: fix nf_synproxy_ipv{4,6}_init() return code

Message ID 20190619125314.1005993-1-arnd@arndb.de
State New
Headers show
Series netfilter: synproxy: fix nf_synproxy_ipv{4,6}_init() return code | expand

Commit Message

Arnd Bergmann June 19, 2019, 12:53 p.m. UTC
We return an uninitialized variable on success:

net/netfilter/nf_synproxy_core.c:793:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (snet->hook_ref4 == 0) {
            ^~~~~~~~~~~~~~~~~~~~

Initialize the return code to zero first.

Fixes: d7f9b2f18eae ("netfilter: synproxy: extract SYNPROXY infrastructure from {ipt, ip6t}_SYNPROXY")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 net/netfilter/nf_synproxy_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.20.0

Comments

Pablo Neira Ayuso June 19, 2019, 4:04 p.m. UTC | #1
On Wed, Jun 19, 2019 at 02:53:07PM +0200, Arnd Bergmann wrote:
> We return an uninitialized variable on success:

> 

> net/netfilter/nf_synproxy_core.c:793:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

>         if (snet->hook_ref4 == 0) {

>             ^~~~~~~~~~~~~~~~~~~~

> 

> Initialize the return code to zero first.


Thanks Arnd. We got a fix for this:

https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git/commit/?id=72c5e11854afb842e157353be0291d65b91725f5
diff mbox series

Patch

diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
index 50677285f82e..283686e972a0 100644
--- a/net/netfilter/nf_synproxy_core.c
+++ b/net/netfilter/nf_synproxy_core.c
@@ -788,7 +788,7 @@  static const struct nf_hook_ops ipv4_synproxy_ops[] = {
 
 int nf_synproxy_ipv4_init(struct synproxy_net *snet, struct net *net)
 {
-	int err;
+	int err = 0;
 
 	if (snet->hook_ref4 == 0) {
 		err = nf_register_net_hooks(net, ipv4_synproxy_ops,
@@ -1213,7 +1213,7 @@  static const struct nf_hook_ops ipv6_synproxy_ops[] = {
 int
 nf_synproxy_ipv6_init(struct synproxy_net *snet, struct net *net)
 {
-	int err;
+	int err = 0;
 
 	if (snet->hook_ref6 == 0) {
 		err = nf_register_net_hooks(net, ipv6_synproxy_ops,