[bug report] xfs: convert kmem_zalloc() to kzalloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Dave Chinner,

The patch 10634530f7ba: "xfs: convert kmem_zalloc() to kzalloc()"
from Jan 16, 2024 (linux-next), leads to the following Smatch static
checker warning:

	fs/xfs/libxfs/xfs_btree_staging.c:416 xfs_btree_bload_prep_block()
	error: potential null dereference 'ifp->if_broot'.  (kzalloc returns null)

fs/xfs/libxfs/xfs_btree_staging.c
    383 STATIC int
    384 xfs_btree_bload_prep_block(
    385         struct xfs_btree_cur                *cur,
    386         struct xfs_btree_bload                *bbl,
    387         struct list_head                *buffers_list,
    388         unsigned int                        level,
    389         unsigned int                        nr_this_block,
    390         union xfs_btree_ptr                *ptrp, /* in/out */
    391         struct xfs_buf                        **bpp, /* in/out */
    392         struct xfs_btree_block                **blockp, /* in/out */
    393         void                                *priv)
    394 {
    395         union xfs_btree_ptr                new_ptr;
    396         struct xfs_buf                        *new_bp;
    397         struct xfs_btree_block                *new_block;
    398         int                                ret;
    399 
    400         if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) &&
    401             level == cur->bc_nlevels - 1) {
    402                 struct xfs_ifork        *ifp = xfs_btree_ifork_ptr(cur);
    403                 size_t                        new_size;
    404 
    405                 ASSERT(*bpp == NULL);
    406 
    407                 /* Allocate a new incore btree root block. */
    408                 new_size = bbl->iroot_size(cur, level, nr_this_block, priv);
    409                 ifp->if_broot = kzalloc(new_size, GFP_KERNEL);

The rest of these were changed to GFP_KERNEL | __GFP_NOFAIL so I suspect
this was an oversight.

    410                 ifp->if_broot_bytes = (int)new_size;
    411 
    412                 /* Initialize it and send it out. */
    413                 xfs_btree_init_block_int(cur->bc_mp, ifp->if_broot,
    414                                 XFS_BUF_DADDR_NULL, cur->bc_btnum, level,
    415                                 nr_this_block, cur->bc_ino.ip->i_ino,
--> 416                                 cur->bc_flags);
    417 
    418                 *bpp = NULL;
    419                 *blockp = ifp->if_broot;
    420                 xfs_btree_set_ptr_null(cur, ptrp);
    421                 return 0;
    422         }

regards,
dan carpenter




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux