]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: removed useless condition in function xfs_attr_node_get
authorAndrey Strachuk <strochuk@ispras.ru>
Fri, 15 Jul 2022 17:51:43 +0000 (10:51 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 26 Jul 2022 19:54:56 +0000 (12:54 -0700)
Source kernel commit: 0f38063d7a38015a47ca1488406bf21e0effe80e

At line 1561, variable "state" is being compared
with NULL every loop iteration.

-------------------------------------------------------------------
1561    for (i = 0; state != NULL && i < state->path.active; i++) {
1562            xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1563            state->path.blk[i].bp = NULL;
1564    }
-------------------------------------------------------------------

However, it cannot be NULL.

----------------------------------------
1546    state = xfs_da_state_alloc(args);
----------------------------------------

xfs_da_state_alloc calls kmem_cache_zalloc. kmem_cache_zalloc is
called with __GFP_NOFAIL flag and, therefore, it cannot return NULL.

--------------------------------------------------------------------------
struct xfs_da_state *
xfs_da_state_alloc(
struct xfs_da_args      *args)
{
struct xfs_da_state     *state;

state = kmem_cache_zalloc(xfs_da_state_cache, GFP_NOFS | __GFP_NOFAIL);
state->args = args;
state->mp = args->dp->i_mount;
return state;
}
--------------------------------------------------------------------------

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Andrey Strachuk <strochuk@ispras.ru>
Fixes: 4d0cdd2bb8f0 ("xfs: clean up xfs_attr_node_hasname")
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_attr.c

index 0897393497d56df22482b48ff2142b55d164a100..b451fcdb2a32a10156794c9b905b05c328b73672 100644 (file)
@@ -1556,7 +1556,7 @@ xfs_attr_node_get(
         * If not in a transaction, we have to release all the buffers.
         */
 out_release:
-       for (i = 0; state != NULL && i < state->path.active; i++) {
+       for (i = 0; i < state->path.active; i++) {
                xfs_trans_brelse(args->trans, state->path.blk[i].bp);
                state->path.blk[i].bp = NULL;
        }