[PATCH] net/irda: remove pointless assignment/check

Subsystems: networking [general], the rest

STALE3655d

2 messages, 2 authors, 2016-08-20 · open the first message on its own page

[PATCH] net/irda: remove pointless assignment/check

From: Vegard Nossum <hidden>
Date: 2016-08-19 16:11:24

We've already set sk to sock->sk and dereferenced it, so if it's NULL
we would have crashed already. Moreover, if it was NULL we would have
crashed anyway when jumping to 'out' and trying to unlock the sock.
Furthermore, if we had assigned a different value to 'sk' we would
have been calling lock_sock() and release_sock() on different sockets.

My conclusion is that these two lines are complete nonsense and only
serve to confuse the reader.

Signed-off-by: Vegard Nossum <redacted>
---
 net/irda/af_irda.c | 3 ---
 1 file changed, 3 deletions(-)
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 8d2f7c9..db63969 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -845,9 +845,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
 	if (sock->state != SS_UNCONNECTED)
 		goto out;
 
-	if ((sk = sock->sk) == NULL)
-		goto out;
-
 	err = -EOPNOTSUPP;
 	if ((sk->sk_type != SOCK_STREAM) && (sk->sk_type != SOCK_SEQPACKET) &&
 	    (sk->sk_type != SOCK_DGRAM))
-- 
2.10.0.rc0.1.g07c9292

Re: [PATCH] net/irda: remove pointless assignment/check

From: David Miller <davem@davemloft.net>
Date: 2016-08-20 01:08:16

From: Vegard Nossum <redacted>
Date: Fri, 19 Aug 2016 18:08:57 +0200
We've already set sk to sock->sk and dereferenced it, so if it's NULL
we would have crashed already. Moreover, if it was NULL we would have
crashed anyway when jumping to 'out' and trying to unlock the sock.
Furthermore, if we had assigned a different value to 'sk' we would
have been calling lock_sock() and release_sock() on different sockets.

My conclusion is that these two lines are complete nonsense and only
serve to confuse the reader.

Signed-off-by: Vegard Nossum <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help