From: Liam Howlett <liam.howlett@oracle.com>
To: kernel test robot <lkp@intel.com>,
"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
"kbuild-all@lists.01.org" <kbuild-all@lists.01.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [linux-next:master 14545/14705] mm/nommu.c:1081:28: warning: variable 'vma' is uninitialized when used here
Date: Thu, 2 Jun 2022 14:11:51 +0000 [thread overview]
Message-ID: <20220602141145.i44sjd3mxvqaofvt@revolver> (raw)
In-Reply-To: <20220602134053.cyuvw7ema33voakf@revolver>
[-- Attachment #1: Type: text/plain, Size: 3200 bytes --]
* Liam R. Howlett <Liam.Howlett@Oracle.com> [220602 09:40]:
> * kernel test robot <lkp@intel.com> [220602 09:24]:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > head: 2e776ccffa840ce53ee1c21bde54cbe4bc102c3b
> > commit: 32355b99dd92f9751a482463d7e239fa06302bc9 [14545/14705] mm/nommu: move preallocations and limit other allocations
> > config: arm-buildonly-randconfig-r004-20220531 (https://download.01.org/0day-ci/archive/20220602/202206022121.RYk2Zgc9-lkp@intel.com/config)
> > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project b364c76683f8ef241025a9556300778c07b590c2)
> > reproduce (this is a W=1 build):
> > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > # install arm cross compiling tool for clang build
> > # apt-get install binutils-arm-linux-gnueabi
> > # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=32355b99dd92f9751a482463d7e239fa06302bc9
> > git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
> > git fetch --no-tags linux-next master
> > git checkout 32355b99dd92f9751a482463d7e239fa06302bc9
> > # save the config file
> > mkdir build_dir && cp config build_dir/.config
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All warnings (new ones prefixed by >>):
> >
> > mm/nommu.c:593:18: error: incompatible pointer types passing 'struct ma_state **' to parameter of type 'struct ma_state *'; remove & [-Werror,-Wincompatible-pointer-types]
> > prev = mas_prev(&mas, 0);
> > ^~~~
> > include/linux/maple_tree.h:468:33: note: passing argument to parameter 'mas' here
> > void *mas_prev(struct ma_state *mas, unsigned long min);
> > ^
> > mm/nommu.c:594:12: error: incompatible pointer types passing 'struct ma_state **' to parameter of type 'struct ma_state *'; remove & [-Werror,-Wincompatible-pointer-types]
> > mas_reset(&mas);
> > ^~~~
> > include/linux/maple_tree.h:505:47: note: passing argument to parameter 'mas' here
> > static inline void mas_reset(struct ma_state *mas)
> > ^
> > >> mm/nommu.c:1081:28: warning: variable 'vma' is uninitialized when used here [-Wuninitialized]
> > if (mas_preallocate(&mas, vma, GFP_KERNEL))
>
> mas_preallocate does not currently use this variable, but in the future
> it may be that you are storing a NULL which could affect the
> preallocations as an optimization. I will fix this by relocating it
> below the vma allocation.
Andrew,
Please find the attached patch to fix up the commit mentioned above
"32355b99dd92f: mm/nommu: move preallocations and limit other
allocations"
Thanks,
Liam
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mm-nommu-Fix-compile-warning-in-do_mmap.patch --]
[-- Type: text/x-diff; name="0001-mm-nommu-Fix-compile-warning-in-do_mmap.patch", Size: 2615 bytes --]
From 0ff3d1d6f0c1d0464cca008acb1a750d78af441e Mon Sep 17 00:00:00 2001
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Date: Thu, 2 Jun 2022 09:44:38 -0400
Subject: [PATCH] mm/nommu: Fix compile warning in do_mmap()
vma is passed in to preallocate nodes since storing NULL could result in
less nodes needed than an actual value being stored. Fix this by moving
the preallocation call to below the vma allocation & be sure to undo
other allocations in the failure path.
Also fix the type error in the short-lived linked list modification.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
mm/nommu.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index dbd73e3a9adf..f6b187090d95 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -590,8 +590,8 @@ static void mas_add_vma_to_mm(struct ma_state *mas, struct mm_struct *mm,
setup_vma_to_mm(vma, mm);
- prev = mas_prev(&mas, 0);
- mas_reset(&mas);
+ prev = mas_prev(mas, 0);
+ mas_reset(mas);
/* add the VMA to the tree */
vma_mas_store(vma, mas);
__vma_link_list(mm, vma, prev);
@@ -1078,9 +1078,6 @@ unsigned long do_mmap(struct file *file,
vm_flags = determine_vm_flags(file, prot, flags, capabilities);
- if (mas_preallocate(&mas, vma, GFP_KERNEL))
- goto error_maple_preallocate;
-
/* we're going to need to record the mapping */
region = kmem_cache_zalloc(vm_region_jar, GFP_KERNEL);
if (!region)
@@ -1090,6 +1087,9 @@ unsigned long do_mmap(struct file *file,
if (!vma)
goto error_getting_vma;
+ if (mas_preallocate(&mas, vma, GFP_KERNEL))
+ goto error_maple_preallocate;
+
region->vm_usage = 1;
region->vm_flags = vm_flags;
region->vm_pgoff = pgoff;
@@ -1262,7 +1262,6 @@ unsigned long do_mmap(struct file *file,
goto error;
error_getting_vma:
- mas_destroy(&mas);
kmem_cache_free(vm_region_jar, region);
pr_warn("Allocation of vma for %lu byte allocation from process %d failed\n",
len, current->pid);
@@ -1270,13 +1269,14 @@ unsigned long do_mmap(struct file *file,
return -ENOMEM;
error_getting_region:
- mas_destroy(&mas);
pr_warn("Allocation of vm region for %lu byte allocation from process %d failed\n",
len, current->pid);
show_free_areas(0, NULL);
return -ENOMEM;
error_maple_preallocate:
+ kmem_cache_free(vm_region_jar, region);
+ vm_area_free(vma);
pr_warn("Allocation of vma tree for process %d failed\n", current->pid);
show_free_areas(0, NULL);
return -ENOMEM;
--
2.35.1
prev parent reply other threads:[~2022-06-02 14:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-02 13:24 kernel test robot
2022-06-02 13:41 ` Liam Howlett
2022-06-02 14:11 ` Liam Howlett [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220602141145.i44sjd3mxvqaofvt@revolver \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=kbuild-all@lists.01.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox