BCC: lkp(a)intel.com CC: kbuild-all(a)lists.01.org In-Reply-To: <20221008093942.3982-1-xupengfei@nfschina.com> References: <20221008093942.3982-1-xupengfei@nfschina.com> TO: XU pengfei TO: akpm(a)linux-foundation.org CC: linux-mm(a)kvack.org CC: linux-kernel(a)vger.kernel.org CC: XU pengfei 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 :::::: branch date: 16 hours ago :::::: commit date: 16 hours ago config: x86_64-randconfig-m001 compiler: gcc-11 (Debian 11.3.0-5) 11.3.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot | Reported-by: Dan Carpenter smatch warnings: mm/mmap_lock.c:218 get_mm_memcg_path() error: uninitialized symbol 'buf'. vim +/buf +218 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