Skip to contentSkip to conversation

mm: fix: Uninitialized variable ret.

PATCH In review YANG LI 3 participants 3 messages Dec 30, 2020 – Jan 5, 2021

Subsystems (3)
lore
Share & tools
lore

YANG LI

author
#0 lore raw

PATCH 1/1 mm: fix: Uninitialized variable ret.

The ret is being used but it isn't being initialized, need to assign a value to it, like 0.

---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index 605f671..15ba17d 100644
@@ -3366,7 +3366,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 {
 	bool enlarge = false;
 	bool drained = false;
-	int ret;
+	int ret = 0;
 	bool limits_invariant;
 	struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · YANG LI <abaci-bugfix-KPsoFbNs7GizrGE5bRqYAgC/[email protected]>…

The ret is being used but it isn't being initialized, need to assign a value to it, like 0.

Hi Yang,

I didn't see where it was used without initialized. Can you point that out to me?

Thanks.

Quoted 23 lines
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -2
index 605f671..15ba17d 100644
@@ -3366,7 +3366,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 {
        bool enlarge = false;
        bool drained = false;
-       int ret;
+       int ret = 0;
        bool limits_invariant;
        struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
 
--

1.8.3.1

#2 lore raw
In reply to YANG LI
Quoted 15 lines · YANG LI

The ret is being used but it isn't being initialized, need to assign a value to it, like 0.

---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +0 -0
index 605f671..15ba17d 100644

mm/memcontrol.c static int mem_cgroup_resize_max(struct mem_cgroup *memcg, · line 3372

Quoted 8 lines
mm/memcontrol.c +1 -1
@@ -3366,7 +3366,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg,
 {
 	bool enlarge = false;
 	bool drained = false;
-	int ret;
+	int ret = 0;
 	bool limits_invariant;
 	struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory;
 

Before every "break" in the loop, we have a "ret = ". The loop runs at least once.

Either I am missing something important, or that patch claims something that does not hold - at least upstream.

Signature · 3 lines
Thanks,

David / dhildenb