Skip to contentSkip to conversation

net: ipv4: Fix the warning for dereference

PATCH Applied Yajun Deng 2 participants 2 messages Aug 30, 2021

Subsystems (3)
lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

PATCH 1/1 net: ipv4: Fix the warning for dereference

Add a if statements to avoid the warning.

Dan Carpenter report:
The patch faf482ca196a: "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)

Fixes faf482ca196a ("net: ipv4: Move ip_options_fragment() out of loop")
---
 net/ipv4/ip_output.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/ip_output.c +3 -1
index 9a8f05d5476e..9bca57ef8b83 100644
@@ -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,
Signature · 1 line
2.32.0
#1 lore raw
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 10 lines · On Mon, 30 Aug 2021 17:16:40 +0800 you wrote:

Add a if statements to avoid the warning.

Dan Carpenter report:
The patch faf482ca196a: "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)

[...]

Here is the summary with links:
- [net-next] net: ipv4: Fix the warning for dereference

    https://git.kernel.org/netdev/net-next/c/1b9fbe813016

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html