mm: initialize return of vm_insert_pages
Subsystems (2)
PATCH 1/1 mm: initialize return of vm_insert_pages
From: Tom Rix <[email protected]>
clang static analysis reports a garbage return
In file included from mm/memory.c:84:mm/memory.c:1612:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
return err;
^~~~~~~~~~The setting of err depends on a loop executing.
So initialize err.
--- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
@@ -1601,7 +1601,7 @@ int vm_insert_pages(struct vm_area_struct *vma, unsigned long addr,return insert_pages (vma, addr, pages, num, vma->vm_page_prot);#else unsigned long idx =0 , pgcount = *num; -int err; +int err =0 ;for (; idx < pgcount; ++idx) { err =vm_insert_page (vma, addr + (PAGE_SIZE * idx), pages[idx]);
Signature · 1 line
2.18.1
Quoted 11 lines · On Fri, Jul 03, 2020 at 07:52:02AM -0700, [email protected] wrote:
From: Tom Rix <[email protected]>
clang static analysis reports a garbage return
In file included from
mm/memory.c:84:mm/memory.c:1612:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]return err; ^~~~~~~~~~The setting of err depends on a loop executing.
So initialize err.
I'd argue that returning zero is wrong. If someone's asked to insert zero pages, that's a nonsense thing to do so it should return -EINVAL..
Quoted 10 lines · Matthew Wilcox
Quoted 9 lines · On Fri, Jul 03, 2020 at 07:52:02AM -0700, [email protected] wrote:
From: Tom Rix <[email protected]>
clang static analysis reports a garbage return
In file included from
mm/memory.c:84:mm/memory.c:1612:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]return err; ^~~~~~~~~~
Quoted 5 lines
Quoted 2 lines
The setting of err depends on a loop executing.
So initialize err.I'd argue that returning zero is wrong. If someone's asked to insert zero pages, that's a nonsense thing to do so it should return
-EINVAL..
good point, i'll respin.