Commit dc4d3f2e authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Pablo Neira Ayuso

netfilter: nf_flow_table_offload: Don't use offset uninitialized in flow_offload_port_{d,s}nat

Clang warns (trimmed the second warning for brevity):

../net/netfilter/nf_flow_table_offload.c:342:2: warning: variable
'offset' is used uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]
        default:
        ^~~~~~~
../net/netfilter/nf_flow_table_offload.c:346:57: note: uninitialized use
occurs here
        flow_offload_mangle(entry, flow_offload_l4proto(flow), offset,
                                                               ^~~~~~
../net/netfilter/nf_flow_table_offload.c:331:12: note: initialize the
variable 'offset' to silence this warning
        u32 offset;
                  ^
                   = 0

Match what was done in the flow_offload_ipv{4,6}_{d,s}nat functions and
just return in the default case, since port would also be uninitialized.

Fixes: c29f74e0 ("netfilter: nf_flow_table: hardware offload support")
Link: https://github.com/ClangBuiltLinux/linux/issues/780Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
Reported-by: default avatarkernelci.org bot <bot@kernelci.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent e0529019
......@@ -340,7 +340,7 @@ static void flow_offload_port_snat(struct net *net,
offset = 0; /* offsetof(struct tcphdr, dest); */
break;
default:
break;
return;
}
flow_offload_mangle(entry, flow_offload_l4proto(flow), offset,
......@@ -367,7 +367,7 @@ static void flow_offload_port_dnat(struct net *net,
offset = 0; /* offsetof(struct tcphdr, dest); */
break;
default:
break;
return;
}
flow_offload_mangle(entry, flow_offload_l4proto(flow), offset,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment