tcp: fix signed/unsigned comparison
Subsystems (3)
PATCH 1/1 tcp: fix signed/unsigned comparison
From: Eric Dumazet <[email protected]>
Kernel test robot reported:
smatch warnings:net/ipv4/tcp_input.c:5966 tcp_rcv_established() warn: unsigned 'reason' is never less than zero.
I actually had one packetdrill failing because of this bug, and was about to send the fix :)
Fixes 4b506af9c5b8 ("tcp: add two drop reasons for tcp_ack()")
Signed-off-by Eric Dumazet <[email protected]>
Reported-by kernel test robot <[email protected]>
--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
@@ -5959,7 +5959,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) step5: reason =tcp_ack (sk, skb,FLAG_SLOWPATH |FLAG_UPDATE_TS_RECENT ); -if (reason <0 ) +if ((int )reason <0 ) goto discard;tcp_rcv_rtt_measure_ts (sk, skb);
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
net/ipv4/tcp_input.c void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) · line 5965
Quoted 13 lines · Eric Dumazet
net/ipv4/tcp_input.c +1
-1@@ -5959,7 +5959,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) step5: reason =tcp_ack (sk, skb,FLAG_SLOWPATH |FLAG_UPDATE_TS_RECENT ); -if (reason <0 ) +if ((int )reason <0 ) goto discard;tcp_rcv_rtt_measure_ts (sk, skb);
Shouldn't reason be negated before passing it to tcp_drop_reason?
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Quoted 15 lines · Andreas Schwab
Quoted 12 lines · Eric Dumazet
net/ipv4/tcp_input.c +1
-1@@ -5959,7 +5959,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) step5: reason =tcp_ack (sk, skb,FLAG_SLOWPATH |FLAG_UPDATE_TS_RECENT ); -if (reason <0 ) +if ((int )reason <0 ) goto discard;
Quoted 3 lines
net/ipv4/tcp_input.c void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) · line 5965
Quoted 1 line
net/ipv4/tcp_input.c +0
-0tcp_rcv_rtt_measure_ts (sk, skb);Shouldn't reason be negated before passing it to
tcp_drop_reason?
Good catch, thanks !