tree:
https://git.kernel.org/pub/scm/linux/kernel/git/colyli/linux-bcache.git for-next
head: 78729af1b480ca5a3edb9547b97b59ed3dd72440
commit: 384227b99f413137d2b0548c364153690be8cbd1 [8/19] bcache: initialize the nvm pages
allocator
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
In file included from drivers/md/bcache/nvm-pages.c:
> drivers/md/bcache/nvm-pages.c:159:4: warning: Either the
condition '!extents' is redundant or there is possible null pointer dereference:
extents. [nullPointerRedundantCheck]
extents->ns = only_set->nss[j];
^
drivers/md/bcache/nvm-pages.c:169:10: note: Assuming that condition '!extents'
is not redundant
if (!extents) {
^
drivers/md/bcache/nvm-pages.c:159:4: note: Null pointer dereference
extents->ns = only_set->nss[j];
^
vim +159 drivers/md/bcache/nvm-pages.c
384227b99f4131 Qiaowei Ren 2021-02-08 115 static int init_owner_info(struct
bch_nvm_namespace *ns)
384227b99f4131 Qiaowei Ren 2021-02-08 116 {
384227b99f4131 Qiaowei Ren 2021-02-08 117 struct bch_owner_list_head *owner_list_head;
384227b99f4131 Qiaowei Ren 2021-02-08 118 struct bch_nvm_pages_owner_head *owner_head;
384227b99f4131 Qiaowei Ren 2021-02-08 119 struct bch_nvm_pgalloc_recs
*nvm_pgalloc_recs;
384227b99f4131 Qiaowei Ren 2021-02-08 120 struct bch_owner_list *owner_list;
384227b99f4131 Qiaowei Ren 2021-02-08 121 struct bch_nvm_alloced_recs *extents;
384227b99f4131 Qiaowei Ren 2021-02-08 122 struct bch_extent *extent;
384227b99f4131 Qiaowei Ren 2021-02-08 123 u32 i, j, k;
384227b99f4131 Qiaowei Ren 2021-02-08 124
384227b99f4131 Qiaowei Ren 2021-02-08 125 owner_list_head = (struct bch_owner_list_head
*)
384227b99f4131 Qiaowei Ren 2021-02-08 126 (ns->kaddr +
BCH_NVM_PAGES_OWNER_LIST_HEAD_OFFSET);
384227b99f4131 Qiaowei Ren 2021-02-08 127
384227b99f4131 Qiaowei Ren 2021-02-08 128 mutex_lock(&only_set->lock);
384227b99f4131 Qiaowei Ren 2021-02-08 129 only_set->owner_list_size =
owner_list_head->size;
384227b99f4131 Qiaowei Ren 2021-02-08 130 only_set->owner_list_used =
owner_list_head->used;
384227b99f4131 Qiaowei Ren 2021-02-08 131
384227b99f4131 Qiaowei Ren 2021-02-08 132 for (i = 0; i < owner_list_head->used;
i++) {
384227b99f4131 Qiaowei Ren 2021-02-08 133 owner_head =
&owner_list_head->heads[i];
384227b99f4131 Qiaowei Ren 2021-02-08 134 owner_list =
alloc_owner_list(owner_head->uuid, owner_head->label,
384227b99f4131 Qiaowei Ren 2021-02-08 135 only_set->total_namespaces_nr);
384227b99f4131 Qiaowei Ren 2021-02-08 136 if (!owner_list) {
384227b99f4131 Qiaowei Ren 2021-02-08 137 mutex_unlock(&only_set->lock);
384227b99f4131 Qiaowei Ren 2021-02-08 138 return -ENOMEM;
384227b99f4131 Qiaowei Ren 2021-02-08 139 }
384227b99f4131 Qiaowei Ren 2021-02-08 140
384227b99f4131 Qiaowei Ren 2021-02-08 141 for (j = 0; j <
only_set->total_namespaces_nr; j++) {
384227b99f4131 Qiaowei Ren 2021-02-08 142 if (!only_set->nss[j] ||
!owner_head->recs[j])
384227b99f4131 Qiaowei Ren 2021-02-08 143 continue;
384227b99f4131 Qiaowei Ren 2021-02-08 144
384227b99f4131 Qiaowei Ren 2021-02-08 145 nvm_pgalloc_recs = (struct
bch_nvm_pgalloc_recs *)
384227b99f4131 Qiaowei Ren 2021-02-08 146 ((long)owner_head->recs[j] +
ns->kaddr);
384227b99f4131 Qiaowei Ren 2021-02-08 147 if (memcmp(nvm_pgalloc_recs->magic,
bch_nvm_pages_pgalloc_magic, 16)) {
384227b99f4131 Qiaowei Ren 2021-02-08 148 pr_info("invalid
bch_nvmpages_pgalloc_magic\n");
384227b99f4131 Qiaowei Ren 2021-02-08 149 mutex_unlock(&only_set->lock);
384227b99f4131 Qiaowei Ren 2021-02-08 150 return -EINVAL;
384227b99f4131 Qiaowei Ren 2021-02-08 151 }
384227b99f4131 Qiaowei Ren 2021-02-08 152
384227b99f4131 Qiaowei Ren 2021-02-08 153 extents = kzalloc(sizeof(*extents),
GFP_KERNEL);
384227b99f4131 Qiaowei Ren 2021-02-08 154 if (!extents) {
384227b99f4131 Qiaowei Ren 2021-02-08 155 mutex_unlock(&only_set->lock);
384227b99f4131 Qiaowei Ren 2021-02-08 156 return -ENOMEM;
384227b99f4131 Qiaowei Ren 2021-02-08 157 }
384227b99f4131 Qiaowei Ren 2021-02-08 158
384227b99f4131 Qiaowei Ren 2021-02-08 @159 extents->ns = only_set->nss[j];
384227b99f4131 Qiaowei Ren 2021-02-08 160
INIT_LIST_HEAD(&extents->extent_head);
384227b99f4131 Qiaowei Ren 2021-02-08 161 owner_list->alloced_recs[j] = extents;
384227b99f4131 Qiaowei Ren 2021-02-08 162
384227b99f4131 Qiaowei Ren 2021-02-08 163 do {
384227b99f4131 Qiaowei Ren 2021-02-08 164 struct bch_pgalloc_rec *rec;
384227b99f4131 Qiaowei Ren 2021-02-08 165
384227b99f4131 Qiaowei Ren 2021-02-08 166 for (k = 0; k <
nvm_pgalloc_recs->used; k++) {
384227b99f4131 Qiaowei Ren 2021-02-08 167 rec = &nvm_pgalloc_recs->recs[k];
384227b99f4131 Qiaowei Ren 2021-02-08 168 extent = kzalloc(sizeof(*extent),
GFP_KERNEL);
384227b99f4131 Qiaowei Ren 2021-02-08 169 if (!extents) {
^^^^^^^
This should be "extent" singular.
384227b99f4131 Qiaowei Ren 2021-02-08 170 mutex_unlock(&only_set->lock);
384227b99f4131 Qiaowei Ren 2021-02-08 171 return -ENOMEM;
384227b99f4131 Qiaowei Ren 2021-02-08 172 }
384227b99f4131 Qiaowei Ren 2021-02-08 173 extent->kaddr =
nvm_pgoff_to_vaddr(extents->ns, rec->pgoff);
384227b99f4131 Qiaowei Ren 2021-02-08 174 extent->nr = rec->nr;
384227b99f4131 Qiaowei Ren 2021-02-08 175 list_add_tail(&extent->list,
&extents->extent_head);
384227b99f4131 Qiaowei Ren 2021-02-08 176 }
384227b99f4131 Qiaowei Ren 2021-02-08 177 extents->nr +=
nvm_pgalloc_recs->used;
384227b99f4131 Qiaowei Ren 2021-02-08 178
384227b99f4131 Qiaowei Ren 2021-02-08 179 if (nvm_pgalloc_recs->next) {
384227b99f4131 Qiaowei Ren 2021-02-08 180 nvm_pgalloc_recs = (struct
bch_nvm_pgalloc_recs *)
384227b99f4131 Qiaowei Ren 2021-02-08 181 ((long)nvm_pgalloc_recs->next +
ns->kaddr);
384227b99f4131 Qiaowei Ren 2021-02-08 182 if (memcmp(nvm_pgalloc_recs->magic,
384227b99f4131 Qiaowei Ren 2021-02-08 183 bch_nvm_pages_pgalloc_magic, 16)) {
384227b99f4131 Qiaowei Ren 2021-02-08 184 pr_info("invalid
bch_nvmpages_pgalloc_magic\n");
384227b99f4131 Qiaowei Ren 2021-02-08 185 mutex_unlock(&only_set->lock);
384227b99f4131 Qiaowei Ren 2021-02-08 186 return -EINVAL;
384227b99f4131 Qiaowei Ren 2021-02-08 187 }
384227b99f4131 Qiaowei Ren 2021-02-08 188 } else
384227b99f4131 Qiaowei Ren 2021-02-08 189 nvm_pgalloc_recs = NULL;
384227b99f4131 Qiaowei Ren 2021-02-08 190 } while (nvm_pgalloc_recs);
384227b99f4131 Qiaowei Ren 2021-02-08 191 }
384227b99f4131 Qiaowei Ren 2021-02-08 192 only_set->owner_lists[i] = owner_list;
384227b99f4131 Qiaowei Ren 2021-02-08 193 owner_list->nvm_set = only_set;
384227b99f4131 Qiaowei Ren 2021-02-08 194 }
384227b99f4131 Qiaowei Ren 2021-02-08 195 mutex_unlock(&only_set->lock);
384227b99f4131 Qiaowei Ren 2021-02-08 196
384227b99f4131 Qiaowei Ren 2021-02-08 197 return 0;
384227b99f4131 Qiaowei Ren 2021-02-08 198 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org