From nobody Mon Sep 15 12:57:16 2025 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 2C3A8C5479D for ; Thu, 12 Jan 2023 01:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbjALBdl (ORCPT ); Wed, 11 Jan 2023 20:33:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235728AbjALBde (ORCPT ); Wed, 11 Jan 2023 20:33:34 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 040F727186 for ; Wed, 11 Jan 2023 17:33:32 -0800 (PST) Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Nsn4n71JbzqV7f; Thu, 12 Jan 2023 09:28:41 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 12 Jan 2023 09:33:28 +0800 From: Peng Zhang To: , , CC: , , , , ZhangPeng , Dan Carpenter Subject: [PATCH -next] fs/ntfs3: Fix potential NULL/IS_ERR bug in ntfs_lookup() Date: Thu, 12 Jan 2023 01:32:48 +0000 Message-ID: <20230112013248.2464556-1-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: ZhangPeng Dan Carpenter reported a Smatch static checker warning: fs/ntfs3/namei.c:96 ntfs_lookup() error: potential NULL/IS_ERR bug 'inode' It will cause null-ptr-deref when dir_search_u() returns NULL if the file is not found. Fix this by replacing IS_ERR() with IS_ERR_OR_NULL() to add a check for NULL. Fixes: fb6b59b5a2d6 ("fs/ntfs3: Fix null-ptr-deref on inode->i_op in ntfs_l= ookup()") Reported-by: Dan Carpenter Signed-off-by: ZhangPeng --- fs/ntfs3/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 3db34d5c03dc..f23c2c26dd08 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -93,7 +93,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, stru= ct dentry *dentry, * If the MFT record of ntfs inode is not a base record, inode->i_op can = be NULL. * This causes null pointer dereference in d_splice_alias(). */ - if (!IS_ERR(inode) && inode->i_op =3D=3D NULL) { + if (!IS_ERR_OR_NULL(inode) && inode->i_op =3D=3D NULL) { iput(inode); inode =3D ERR_PTR(-EINVAL); } --=20 2.25.1