Re: [PATCH] ocfs2/dlm: Clean up errors in dlmdomain.c

From: kernel test robot
Date: Thu Oct 19 2023 - 05:54:13 EST


Hi KaiLong,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.6-rc6 next-20231019]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/KaiLong-Wang/ocfs2-dlm-Clean-up-errors-in-dlmdomain-c/20231017-115916
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/62e91e34.969.18b27f9ec40.Coremail.wangkailong%40jari.cn
patch subject: [PATCH] ocfs2/dlm: Clean up errors in dlmdomain.c
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20231019/202310191736.myy5k3i6-lkp@xxxxxxxxx/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231019/202310191736.myy5k3i6-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310191736.myy5k3i6-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

fs/ocfs2/dlm/dlmdomain.c: In function 'dlm_alloc_pagevec':
fs/ocfs2/dlm/dlmdomain.c:78:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
78 | for (i = 0; i < pages; i++)
| ^~~
fs/ocfs2/dlm/dlmdomain.c:80:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
80 | if (!(vec[i]))
| ^~
fs/ocfs2/dlm/dlmdomain.c: In function 'dlm_alloc_pagevec.constprop':
>> fs/ocfs2/dlm/dlmdomain.c:80:26: warning: array subscript 32 is outside array bounds of 'void[128]' [-Warray-bounds=]
80 | if (!(vec[i]))
| ~~~~^~~~
In file included from fs/ocfs2/dlm/dlmdomain.c:12:
In function 'kmalloc',
inlined from 'kmalloc_array' at include/linux/slab.h:635:10,
inlined from 'dlm_alloc_pagevec.constprop' at fs/ocfs2/dlm/dlmdomain.c:72:15:
include/linux/slab.h:599:24: note: at offset 128 into object of size 128 allocated by 'kmalloc_trace'
599 | return kmalloc_trace(
| ^~~~~~~~~~~~~~
600 | kmalloc_caches[kmalloc_type(flags, _RET_IP_)][index],
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
601 | flags, size);
| ~~~~~~~~~~~~


vim +80 fs/ocfs2/dlm/dlmdomain.c

69
70 static void **dlm_alloc_pagevec(int pages)
71 {
72 void **vec = kmalloc_array(pages, sizeof(void *), GFP_KERNEL);
73 int i;
74
75 if (!vec)
76 return NULL;
77
78 for (i = 0; i < pages; i++)
79 vec[i] = (void *)__get_free_page(GFP_KERNEL);
> 80 if (!(vec[i]))
81 goto out_free;
82
83 mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
84 pages, (unsigned long)DLM_HASH_PAGES,
85 (unsigned long)DLM_BUCKETS_PER_PAGE);
86 return vec;
87 out_free:
88 dlm_free_pagevec(vec, i);
89 return NULL;
90 }
91

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki