Skip to contentSkip to conversation

tcp_memcontrol: fix reversed if condition

PATCH Applied Dan Carpenter 2 participants 2 messages Dec 15, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp_memcontrol: fix reversed if condition

We should only dereference the pointer if it's valid, not the other way round.

net/ipv4/tcp_memcontrol.c +1 -1
index 171d7b6..7fed04f 100644
@@ -44,7 +44,7 @@ static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto)
 
 static void memcg_tcp_enter_memory_pressure(struct sock *sk)
 {
-	if (!sk->sk_cgrp->memory_pressure)
+	if (sk->sk_cgrp->memory_pressure)
 		*sk->sk_cgrp->memory_pressure = 1;
 }
 EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure);
maintainer Applied
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Thu, 15 Dec 2011 14:05:10 +0300

Quoted 4 lines

We should only dereference the pointer if it's valid, not the other way round.

It's nice to see how thoroughly this code has been tested, sigh...

Applied, thanks a lot Dan.

Quoted 13 lines
net/ipv4/tcp_memcontrol.c +1 -1
index 171d7b6..7fed04f 100644
@@ -44,7 +44,7 @@ static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto)
 
 static void memcg_tcp_enter_memory_pressure(struct sock *sk)
 {
-	if (!sk->sk_cgrp->memory_pressure)
+	if (sk->sk_cgrp->memory_pressure)
 		*sk->sk_cgrp->memory_pressure = 1;
 }
 EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure);