Skip to content

Commit

Permalink
tcp: fix signed/unsigned comparison
Browse files Browse the repository at this point in the history
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 :)

v2: Andreas Schwab also pointed out that @Reason needs to be negated
    before we reach tcp_drop_reason()

Fixes: 4b506af ("tcp: add two drop reasons for tcp_ack()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and davem330 committed Apr 18, 2022
1 parent 53c33a1 commit 843f774
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/ipv4/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -5959,9 +5959,10 @@ 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) {
reason = -reason;
goto discard;

}
tcp_rcv_rtt_measure_ts(sk, skb);

/* Process urgent data. */
Expand Down

0 comments on commit 843f774

Please sign in to comment.