From nobody Sun Apr 19 03:58:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC57CCA47F for ; Wed, 6 Jul 2022 13:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232632AbiGFNgw (ORCPT ); Wed, 6 Jul 2022 09:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232239AbiGFNgu (ORCPT ); Wed, 6 Jul 2022 09:36:50 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED44B5F66; Wed, 6 Jul 2022 06:36:48 -0700 (PDT) Received: from andrey-lpc.intra.ispras.ru (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPS id D6A4740737B9; Wed, 6 Jul 2022 13:36:44 +0000 (UTC) From: Andrey Strachuk To: "Darrick J. Wong" Cc: Andrey Strachuk , Dave Chinner , Allison Henderson , Chandan Babu R , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] xfs: removed useless condition in function xfs_attr_node_get Date: Wed, 6 Jul 2022 16:36:27 +0300 Message-Id: <20220706133627.11198-1-strochuk@ispras.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" At line 1561, variable "state" is being compared with NULL every loop iteration. Reviewed-by: Darrick J. Wong ------------------------------------------------------------------- 1561 for (i =3D 0; state !=3D NULL && i < state->path.active; i++) { 1562 xfs_trans_brelse(args->trans, state->path.blk[i].bp); 1563 state->path.blk[i].bp =3D NULL; 1564 } ------------------------------------------------------------------- However, it cannot be NULL. ---------------------------------------- 1546 state =3D 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 =3D kmem_cache_zalloc(xfs_da_state_cache, GFP_NOFS | __GFP_NOFAIL); state->args =3D args; state->mp =3D args->dp->i_mount; return state; } -------------------------------------------------------------------------- Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Andrey Strachuk Fixes: 4d0cdd2bb8f0 ("xfs: clean up xfs_attr_node_hasname") --- fs/xfs/libxfs/xfs_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 224649a76cbb..6b8857e53add 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1558,7 +1558,7 @@ xfs_attr_node_get( * If not in a transaction, we have to release all the buffers. */ out_release: - for (i =3D 0; state !=3D NULL && i < state->path.active; i++) { + for (i =3D 0; i < state->path.active; i++) { xfs_trans_brelse(args->trans, state->path.blk[i].bp); state->path.blk[i].bp =3D NULL; } --=20 2.25.1