Commit 1b9fbe81 authored by Yajun Deng's avatar Yajun Deng Committed by David S. Miller

net: ipv4: Fix the warning for dereference

Add a if statements to avoid the warning.

Dan Carpenter report:
The patch faf482ca: "net: ipv4: Move ip_options_fragment() out of
loop" from Aug 23, 2021, leads to the following Smatch complaint:

    net/ipv4/ip_output.c:833 ip_do_fragment()
    warn: variable dereferenced before check 'iter.frag' (see line 828)
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Fixes: faf482ca ("net: ipv4: Move ip_options_fragment() out of loop")
Link: https://lore.kernel.org/netdev/20210830073802.GR7722@kadam/T/#tSigned-off-by: default avatarYajun Deng <yajun.deng@linux.dev>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aaa8e492
......@@ -825,7 +825,9 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
/* Everything is OK. Generate! */
ip_fraglist_init(skb, iph, hlen, &iter);
ip_options_fragment(iter.frag);
if (iter.frag)
ip_options_fragment(iter.frag);
for (;;) {
/* Prepare header of the next frame,
......
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