lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sat, 8 Oct 2022 21:14:34 +0800
From:   kernel test robot <lkp@...el.com>
To:     XU pengfei <xupengfei@...china.com>, akpm@...ux-foundation.org
Cc:     llvm@...ts.linux.dev, kbuild-all@...ts.01.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, XU pengfei <xupengfei@...china.com>
Subject: Re: [PATCH 1/1] mm/mmap_lock: Remove unnecessary 'NULL' values from
 Pointer

Hi XU,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/XU-pengfei/mm-mmap_lock-Remove-unnecessary-NULL-values-from-Pointer/20221008-174149
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: x86_64-randconfig-a003-20221003
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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
        # https://github.com/intel-lab-lkp/linux/commit/d8ed9ca4f5c0538ddfb42265c5f91cc185aa0507
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review XU-pengfei/mm-mmap_lock-Remove-unnecessary-NULL-values-from-Pointer/20221008-174149
        git checkout d8ed9ca4f5c0538ddfb42265c5f91cc185aa0507
        # 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=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

All warnings (new ones prefixed by >>):

>> mm/mmap_lock.c:206:6: warning: variable 'buf' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (unlikely(memcg->css.cgroup == NULL))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:22: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/mmap_lock.c:218:9: note: uninitialized use occurs here
           return buf;
                  ^~~
   mm/mmap_lock.c:206:2: note: remove the 'if' if its condition is always false
           if (unlikely(memcg->css.cgroup == NULL))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/mmap_lock.c:204:6: warning: variable 'buf' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (memcg == NULL)
               ^~~~~~~~~~~~~
   mm/mmap_lock.c:218:9: note: uninitialized use occurs here
           return buf;
                  ^~~
   mm/mmap_lock.c:204:2: note: remove the 'if' if its condition is always false
           if (memcg == NULL)
           ^~~~~~~~~~~~~~~~~~
   mm/mmap_lock.c:201:11: note: initialize the variable 'buf' to silence this warning
           char *buf;
                    ^
                     = NULL
   2 warnings generated.


vim +206 mm/mmap_lock.c

d01079f3d0c0a9 Mel Gorman     2021-06-30  184  
d01079f3d0c0a9 Mel Gorman     2021-06-30  185  #ifdef CONFIG_TRACING
d01079f3d0c0a9 Mel Gorman     2021-06-30  186  #ifdef CONFIG_MEMCG
2b5067a8143e34 Axel Rasmussen 2020-12-14  187  /*
2b5067a8143e34 Axel Rasmussen 2020-12-14  188   * Write the given mm_struct's memcg path to a percpu buffer, and return a
2b5067a8143e34 Axel Rasmussen 2020-12-14  189   * pointer to it. If the path cannot be determined, or no buffer was available
2b5067a8143e34 Axel Rasmussen 2020-12-14  190   * (because the trace event is being unregistered), NULL is returned.
2b5067a8143e34 Axel Rasmussen 2020-12-14  191   *
2b5067a8143e34 Axel Rasmussen 2020-12-14  192   * Note: buffers are allocated per-cpu to avoid locking, so preemption must be
2b5067a8143e34 Axel Rasmussen 2020-12-14  193   * disabled by the caller before calling us, and re-enabled only after the
2b5067a8143e34 Axel Rasmussen 2020-12-14  194   * caller is done with the pointer.
2b5067a8143e34 Axel Rasmussen 2020-12-14  195   *
2b5067a8143e34 Axel Rasmussen 2020-12-14  196   * The caller must call put_memcg_path_buf() once the buffer is no longer
2b5067a8143e34 Axel Rasmussen 2020-12-14  197   * needed. This must be done while preemption is still disabled.
2b5067a8143e34 Axel Rasmussen 2020-12-14  198   */
2b5067a8143e34 Axel Rasmussen 2020-12-14  199  static const char *get_mm_memcg_path(struct mm_struct *mm)
2b5067a8143e34 Axel Rasmussen 2020-12-14  200  {
d8ed9ca4f5c053 XU pengfei     2022-10-08  201  	char *buf;
2b5067a8143e34 Axel Rasmussen 2020-12-14  202  	struct mem_cgroup *memcg = get_mem_cgroup_from_mm(mm);
2b5067a8143e34 Axel Rasmussen 2020-12-14  203  
2b5067a8143e34 Axel Rasmussen 2020-12-14  204  	if (memcg == NULL)
2b5067a8143e34 Axel Rasmussen 2020-12-14  205  		goto out;
2b5067a8143e34 Axel Rasmussen 2020-12-14 @206  	if (unlikely(memcg->css.cgroup == NULL))
2b5067a8143e34 Axel Rasmussen 2020-12-14  207  		goto out_put;
2b5067a8143e34 Axel Rasmussen 2020-12-14  208  
2b5067a8143e34 Axel Rasmussen 2020-12-14  209  	buf = get_memcg_path_buf();
2b5067a8143e34 Axel Rasmussen 2020-12-14  210  	if (buf == NULL)
2b5067a8143e34 Axel Rasmussen 2020-12-14  211  		goto out_put;
2b5067a8143e34 Axel Rasmussen 2020-12-14  212  
2b5067a8143e34 Axel Rasmussen 2020-12-14  213  	cgroup_path(memcg->css.cgroup, buf, MEMCG_PATH_BUF_SIZE);
2b5067a8143e34 Axel Rasmussen 2020-12-14  214  
2b5067a8143e34 Axel Rasmussen 2020-12-14  215  out_put:
2b5067a8143e34 Axel Rasmussen 2020-12-14  216  	css_put(&memcg->css);
2b5067a8143e34 Axel Rasmussen 2020-12-14  217  out:
2b5067a8143e34 Axel Rasmussen 2020-12-14  218  	return buf;
2b5067a8143e34 Axel Rasmussen 2020-12-14  219  }
2b5067a8143e34 Axel Rasmussen 2020-12-14  220  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (136127 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ