lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1450906240-21821-1-git-send-email-ross.zwisler@linux.intel.com>
Date:	Wed, 23 Dec 2015 14:30:40 -0700
From:	Ross Zwisler <ross.zwisler@...ux.intel.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Tejun Heo <tj@...nel.org>
Cc:	Ross Zwisler <ross.zwisler@...ux.intel.com>,
	Li Zefan <lizefan@...wei.com>,
	Daniel Wagner <daniel.wagner@...-carit.de>,
	Johannes Weiner <hannes@...xchg.org>, cgroups@...r.kernel.org,
	linux-kernel@...r.kernel.org, Dave Jones <davej@...emonkey.org.uk>,
	kernel-team@...com, Aleksa Sarai <cyphar@...har.com>,
	Michal Hocko <mhocko@...nel.org>,
	Ingo Molnar <mingo@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Neil Horman <nhorman@...driver.com>
Subject: [PATCH] cgroup: Fix uninitialized variable warning

Commit 1f7dd3e5a6e4 ("cgroup: fix handling of multi-destination migration
from subtree_control enabling") introduced the following compiler warning:

mm/memcontrol.c: In function ‘mem_cgroup_can_attach’:
mm/memcontrol.c:4790:9: warning: ‘memcg’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   mc.to = memcg;
         ^
Fix this by initializing 'memcg' to NULL and then verifying that it is set
to a value before dereferencing it.

Signed-off-by: Ross Zwisler <ross.zwisler@...ux.intel.com>
---

This issue is present in v4.4-rc5 and later.

---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e234c21..69a28b3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4782,7 +4782,7 @@ static void mem_cgroup_clear_mc(void)
 static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
 {
 	struct cgroup_subsys_state *css;
-	struct mem_cgroup *memcg;
+	struct mem_cgroup *memcg = NULL;
 	struct mem_cgroup *from;
 	struct task_struct *leader, *p;
 	struct mm_struct *mm;
@@ -4805,7 +4805,7 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
 		p = leader;
 		memcg = mem_cgroup_from_css(css);
 	}
-	if (!p)
+	if (!p || !memcg)
 		return 0;
 
 	/*
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ