linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Change judgment len position
@ 2018-10-24 15:47 Wang Hai
  2018-10-24 15:57 ` Willy Tarreau
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Wang Hai @ 2018-10-24 15:47 UTC (permalink / raw)
  To: edumazet; +Cc: davem, kuznet, yoshfuji, netdev, linux-kernel, Wang Hai

To determine whether len is less than zero, it should be put before 
the function min_t, because the return value of min_t is not likely 
to be less than zero.

Signed-off-by: Wang Hai <wanghaifine@gmail.com>
---
 net/ipv4/tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 10c624639..49af9fdc3 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3301,11 +3301,11 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
 	struct net *net = sock_net(sk);
 	int val, len;
 
+	len = min_t(unsigned int, len, sizeof(int));
+
 	if (get_user(len, optlen))
 		return -EFAULT;
 
-	len = min_t(unsigned int, len, sizeof(int));
-
 	if (len < 0)
 		return -EINVAL;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2018-10-25  3:20 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24 15:47 [PATCH] Change judgment len position Wang Hai
2018-10-24 15:57 ` Willy Tarreau
2018-10-24 16:23   ` Joe Perches
2018-10-24 16:32     ` Willy Tarreau
2018-10-24 16:54       ` Joe Perches
2018-10-24 17:03         ` Eric Dumazet
2018-10-24 17:18           ` Joe Perches
2018-10-24 20:09           ` Willy Tarreau
2018-10-24 15:59 ` Eric Dumazet
2018-10-24 16:01   ` Willy Tarreau
2018-10-24 17:10 ` David Miller
2018-10-24 18:28   ` Joe Perches
2018-10-24 20:48     ` Willy Tarreau
2018-10-24 23:46       ` Joe Perches
2018-10-25  0:02         ` David Miller
2018-10-25  0:23           ` Joe Perches
2018-10-25  0:50             ` Eric Dumazet
2018-10-25  1:11         ` Fengguang Wu
2018-10-25  1:16           ` Joe Perches
2018-10-25  2:20             ` Al Viro
2018-10-25  2:41               ` Joe Perches
2018-10-25  3:20                 ` Willy Tarreau
2018-10-25  1:03     ` Al Viro
2018-10-24 17:34 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).