Skip to contentSkip to conversation

percpu: fix pcpu_page_first_chunk return code handling

PATCH In review Arnd Bergmann 2 participants 2 messages Jul 8, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 percpu: fix pcpu_page_first_chunk return code handling

gcc complains that pcpu_page_first_chunk() might return an uninitialized error code when the loop is never entered:

mm/percpu.c: In function 'pcpu_page_first_chunk':
mm/percpu.c:2929:9: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Make it return zero like before the cleanup.

Fixes a13e0ad81216 ("percpu: Make pcpu_setup_first_chunk() void function")
---
 mm/percpu.c | 1 +
 1 file changed, 1 insertion(+)
mm/percpu.c +1 -0
index 5a918a4b1da0..5b65f753c575 100644
@@ -2917,6 +2917,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
 		ai->reserved_size, ai->dyn_size);
 
 	pcpu_setup_first_chunk(ai, vm.addr);
+	rc = 0;
 	goto out_free_ar;
 
 enomem:
Signature · 1 line
2.20.0
maintainer
#1 lore raw
Quoted 29 lines · Arnd Bergmann

gcc complains that pcpu_page_first_chunk() might return an uninitialized error code when the loop is never entered:

mm/percpu.c: In function 'pcpu_page_first_chunk':
mm/percpu.c:2929:9: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Make it return zero like before the cleanup.

Fixes a13e0ad81216 ("percpu: Make pcpu_setup_first_chunk() void function")
---
 mm/percpu.c | 1 +
 1 file changed, 1 insertion(+)
mm/percpu.c +1 -0
index 5a918a4b1da0..5b65f753c575 100644
@@ -2917,6 +2917,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
 		ai->reserved_size, ai->dyn_size);
 
 	pcpu_setup_first_chunk(ai, vm.addr);
+	rc = 0;
 	goto out_free_ar;
 
 enomem:
Signature · 1 line
2.20.0

Hi Arnd,

I got the report for the kbuild bot. I have the fix in my tree already.

Thanks,
Dennis