* [bcache:for-next 8/19] drivers/md/bcache/nvm-pages.c:159:4: warning: Either the condition '!extents' is redundant or there is possible null pointer dereference: extents.
@ 2021-02-10 13:11 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-02-10 13:11 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 7775 bytes --]
CC: kbuild-all(a)lists.01.org
TO: Qiaowei Ren <qiaowei.ren@intel.com>
CC: Coly Li <colyli@suse.de>
CC: Jianpeng Ma <jianpeng.ma@intel.com>
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
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
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@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 114
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) {
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 }
384227b99f4131 Qiaowei Ren 2021-02-08 199
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* [bcache:for-next 8/19] drivers/md/bcache/nvm-pages.c:159:4: warning: Either the condition '!extents' is redundant or there is possible null pointer dereference: extents.
@ 2021-02-10 13:16 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-02-10 13:16 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 7763 bytes --]
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@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(a)lists.01.org
_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-10 13:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 13:11 [bcache:for-next 8/19] drivers/md/bcache/nvm-pages.c:159:4: warning: Either the condition '!extents' is redundant or there is possible null pointer dereference: extents kernel test robot
2021-02-10 13:16 Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.