fs/xfs/libxfs/xfs_btree_staging.c:144 xfs_btree_stage_afakeroot() error: potential null dereference 'nops'. (kmem_alloc returns null)

From: kbuild test robot
Date: Fri May 29 2020 - 17:32:45 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 75caf310d16cc5e2f851c048cd597f5437013368
commit: e06536a692e032470130af5b2136b519595809da xfs: introduce fake roots for ag-rooted btrees
date: 2 months ago
config: i386-randconfig-m021-20200529 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

smatch warnings:
fs/xfs/libxfs/xfs_btree_staging.c:144 xfs_btree_stage_afakeroot() error: potential null dereference 'nops'. (kmem_alloc returns null)

vim +/nops +144 fs/xfs/libxfs/xfs_btree_staging.c

125
126 /*
127 * Initialize a AG-rooted btree cursor with the given AG btree fake root.
128 * The btree cursor's bc_ops will be overridden as needed to make the staging
129 * functionality work.
130 */
131 void
132 xfs_btree_stage_afakeroot(
133 struct xfs_btree_cur *cur,
134 struct xbtree_afakeroot *afake)
135 {
136 struct xfs_btree_ops *nops;
137
138 ASSERT(!(cur->bc_flags & XFS_BTREE_STAGING));
139 ASSERT(!(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE));
140 ASSERT(cur->bc_tp == NULL);
141
142 nops = kmem_alloc(sizeof(struct xfs_btree_ops), KM_NOFS);
143 memcpy(nops, cur->bc_ops, sizeof(struct xfs_btree_ops));
> 144 nops->alloc_block = xfs_btree_fakeroot_alloc_block;
145 nops->free_block = xfs_btree_fakeroot_free_block;
146 nops->init_ptr_from_cur = xfs_btree_fakeroot_init_ptr_from_cur;
147 nops->set_root = xfs_btree_afakeroot_set_root;
148 nops->dup_cursor = xfs_btree_fakeroot_dup_cursor;
149
150 cur->bc_ag.afake = afake;
151 cur->bc_nlevels = afake->af_levels;
152 cur->bc_ops = nops;
153 cur->bc_flags |= XFS_BTREE_STAGING;
154 }
155

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip