diff mbox series

mm: fix: Uninitialized variable ret.

Message ID 1609311551-97108-1-git-send-email-abaci-bugfix@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series mm: fix: Uninitialized variable ret. | expand

Commit Message

Abaci Team Dec. 30, 2020, 6:59 a.m. UTC
The ret is being used but it isn't being initialized,
need to assign a value to it, like 0.

Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
Reported-by: Abaci <abaci@linux.alibaba.com>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Muchun Song Dec. 30, 2020, 7:10 a.m. UTC | #1
YANG LI <abaci-bugfix@linux.alibaba.com> 于2020年12月30日周三 下午3:02写道:
>
> 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.


>
> Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
> Reported-by: Abaci <abaci@linux.alibaba.com>
> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 605f671..15ba17d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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
>
David Hildenbrand Jan. 5, 2021, 11:03 a.m. UTC | #2
On 30.12.20 07:59, YANG LI wrote:
> The ret is being used but it isn't being initialized,
> need to assign a value to it, like 0.
> 
> Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
> Reported-by: Abaci <abaci@linux.alibaba.com>
> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 605f671..15ba17d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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.
diff mbox series

Patch

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 605f671..15ba17d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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;