Re: [mmotm:master 207/422] mm/memcontrol.c:5884:5: warning: 'ret' may be used uninitialized in this function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shame on me :-( I wonder why my compiler didn't complain...

The patch fixing this is attached. Andrew, could you please apply it?

Thank you and sorry for the inconvenience.

On 01/10/2014 05:38 AM, kbuild test robot wrote:
> tree:   git://git.cmpxchg.org/linux-mmotm.git master
> head:   3fe55fa60ae65a3c8348ae1bfc6fd2e5c3f10654
> commit: f44aea42422dcbc58cd8cc4fc8c564b91a283cef [207/422] memcg: rework memcg_update_kmem_limit synchronization
> config: x86_64-randconfig-c2-0110 (attached as .config)
>
> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
>
> All warnings:
>
>    mm/memcontrol.c: In function 'mem_cgroup_css_online':
>>> mm/memcontrol.c:5884:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
>      if (ret)
>         ^
>    mm/memcontrol.c:5192:6: note: 'ret' was declared here
>      int ret;
>          ^
>
> vim +/ret +5884 mm/memcontrol.c
>
> 3c11ecf4 KAMEZAWA Hiroyuki 2010-05-26  5868  		return -EINVAL;
> 3c11ecf4 KAMEZAWA Hiroyuki 2010-05-26  5869  	}
> c0ff4b85 Raghavendra K T   2011-11-02  5870  	memcg->oom_kill_disable = val;
> 4d845ebf KAMEZAWA Hiroyuki 2010-06-29  5871  	if (!val)
> c0ff4b85 Raghavendra K T   2011-11-02  5872  		memcg_oom_recover(memcg);
> 0999821b Glauber Costa     2013-02-22  5873  	mutex_unlock(&memcg_create_mutex);
> 3c11ecf4 KAMEZAWA Hiroyuki 2010-05-26  5874  	return 0;
> 3c11ecf4 KAMEZAWA Hiroyuki 2010-05-26  5875  }
> 3c11ecf4 KAMEZAWA Hiroyuki 2010-05-26  5876  
> c255a458 Andrew Morton     2012-07-31  5877  #ifdef CONFIG_MEMCG_KMEM
> cbe128e3 Glauber Costa     2012-04-09  5878  static int memcg_init_kmem(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
> e5671dfa Glauber Costa     2011-12-11  5879  {
> 55007d84 Glauber Costa     2012-12-18  5880  	int ret;
> 55007d84 Glauber Costa     2012-12-18  5881  
> 2633d7a0 Glauber Costa     2012-12-18  5882  	memcg->kmemcg_id = -1;
> 55007d84 Glauber Costa     2012-12-18  5883  	ret = memcg_propagate_kmem(memcg);
> 55007d84 Glauber Costa     2012-12-18 @5884  	if (ret)
> 55007d84 Glauber Costa     2012-12-18  5885  		return ret;
> 2633d7a0 Glauber Costa     2012-12-18  5886  
> 1d62e436 Glauber Costa     2012-04-09  5887  	return mem_cgroup_sockets_init(memcg, ss);
> 573b400d Michel Lespinasse 2013-04-29  5888  }
> e5671dfa Glauber Costa     2011-12-11  5889  
> 10d5ebf4 Li Zefan          2013-07-08  5890  static void memcg_destroy_kmem(struct mem_cgroup *memcg)
> d1a4c0b3 Glauber Costa     2011-12-11  5891  {
> 1d62e436 Glauber Costa     2012-04-09  5892  	mem_cgroup_sockets_destroy(memcg);
>
> :::::: The code at line 5884 was first introduced by commit
> :::::: 55007d849759252ddd573aeb36143b947202d509 memcg: allocate memory for memcg caches whenever a new memcg appears
>
> :::::: TO: Glauber Costa <glommer@xxxxxxxxxxxxx>
> :::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
>
> ---
> 0-DAY kernel build testing backend              Open Source Technology Center
> http://lists.01.org/mailman/listinfo/kbuild                 Intel Corporation

>From f6c4a5eb38211b79beaa1b571054c9649ca6cb75 Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov@xxxxxxxxxxxxx>
Date: Fri, 10 Jan 2014 10:43:20 +0400
Subject: [PATCH] memcg: fix uninitialized var in memcg_propagate_kmem

mm/memcontrol.c: In function 'mem_cgroup_css_online':
mm/memcontrol.c:5884:5: warning: 'ret' may be used uninitialized in this
function [-Wmaybe-uninitialized]

Signed-off-by: Vladimir Davydov <vdavydov@xxxxxxxxxxxxx>
---
 mm/memcontrol.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2a24789..081c58c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5227,7 +5227,7 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
 
 static int memcg_propagate_kmem(struct mem_cgroup *memcg)
 {
-	int ret;
+	int ret = 0;
 	struct mem_cgroup *parent = parent_mem_cgroup(memcg);
 
 	if (!parent)
-- 
1.7.1


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]