linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memcg: Fix NULL pointer deref in task_in_mem_cgroup()
@ 2014-10-23 16:47 Jan Kara
  2014-10-23 18:19 ` Johannes Weiner
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kara @ 2014-10-23 16:47 UTC (permalink / raw)
  To: Michal Hocko; +Cc: cgroups, linux-mm, Jan Kara

'curr' pointer in task_in_mem_cgroup() can be NULL when we race with
somebody clearing task->mm. Check for it before dereferencing the
pointer.

Coverity-id: 1198369
Signed-off-by: Jan Kara <jack@suse.cz>
---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 23976fd885fd..18ab127a0767 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1469,7 +1469,8 @@ bool task_in_mem_cgroup(struct task_struct *task,
 	 * hierarchy(even if use_hierarchy is disabled in "memcg").
 	 */
 	ret = mem_cgroup_same_or_subtree(memcg, curr);
-	css_put(&curr->css);
+	if (curr)
+		css_put(&curr->css);
 	return ret;
 }
 
-- 
1.8.1.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2014-10-24 13:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-23 16:47 [PATCH] memcg: Fix NULL pointer deref in task_in_mem_cgroup() Jan Kara
2014-10-23 18:19 ` Johannes Weiner
2014-10-23 18:34   ` Jan Kara
2014-10-23 19:38     ` Johannes Weiner
2014-10-24  8:58   ` Michal Hocko
2014-10-24 13:36     ` Johannes Weiner
2014-10-24 13:42       ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox