diff mbox

[1/1] net: ipv4: Remove redundant NULL check

Message ID 1362482829-10455-1-git-send-email-sachin.kamat@linaro.org
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Sachin Kamat March 5, 2013, 11:27 a.m. UTC
kfree on a null pointer is a NO-OP. Hence null check is not necessary.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
Compile tested on linux-next tree (20130305).
---
 net/ipv4/tcp.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Comments

David Miller March 5, 2013, 7:40 p.m. UTC | #1
From: Sachin Kamat <sachin.kamat@linaro.org>
Date: Tue,  5 Mar 2013 16:57:09 +0530

> kfree on a null pointer is a NO-OP. Hence null check is not necessary.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Unnecessary writes to the socket struct should be avoided, as it
generates unnecessary write traffic to the L2 cache.

I'm not applying this.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sachin Kamat March 6, 2013, 3:15 a.m. UTC | #2
On 6 March 2013 01:10, David Miller <davem@davemloft.net> wrote:
> From: Sachin Kamat <sachin.kamat@linaro.org>
> Date: Tue,  5 Mar 2013 16:57:09 +0530
>
>> kfree on a null pointer is a NO-OP. Hence null check is not necessary.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>
> Unnecessary writes to the socket struct should be avoided, as it
> generates unnecessary write traffic to the L2 cache.

Sounds reasonable.

>
> I'm not applying this.

Ok. No problem.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 47e854f..3aa5d54 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -992,10 +992,8 @@  static inline int select_size(const struct sock *sk, bool sg)
 
 void tcp_free_fastopen_req(struct tcp_sock *tp)
 {
-	if (tp->fastopen_req != NULL) {
-		kfree(tp->fastopen_req);
-		tp->fastopen_req = NULL;
-	}
+	kfree(tp->fastopen_req);
+	tp->fastopen_req = NULL;
 }
 
 static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *size)