From: Peng Zhang <zhangpeng362@huawei.com>
To: <almaz.alexandrovich@paragon-software.com>,
<kari.argillander@gmail.com>, <akpm@linux-foundation.org>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<sunnanyong@huawei.com>, <wangkefeng.wang@huawei.com>,
ZhangPeng <zhangpeng362@huawei.com>,
Dan Carpenter <error27@gmail.com>
Subject: [PATCH -next] fs/ntfs3: Fix potential NULL/IS_ERR bug in ntfs_lookup()
Date: Thu, 12 Jan 2023 01:32:48 +0000 [thread overview]
Message-ID: <20230112013248.2464556-1-zhangpeng362@huawei.com> (raw)
From: ZhangPeng <zhangpeng362@huawei.com>
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_lookup()")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
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, struct 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 == NULL) {
+ if (!IS_ERR_OR_NULL(inode) && inode->i_op == NULL) {
iput(inode);
inode = ERR_PTR(-EINVAL);
}
--
2.25.1
next reply other threads:[~2023-01-12 1:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 1:32 Peng Zhang [this message]
2023-01-12 3:43 ` [PATCH -next] fs/ntfs3: Fix potential NULL/IS_ERR bug in ntfs_lookup() Al Viro
2023-01-12 4:11 ` Al Viro
2023-01-13 10:05 ` Konstantin Komarov
2023-01-16 20:18 ` Al Viro
2023-01-16 20:34 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230112013248.2464556-1-zhangpeng362@huawei.com \
--to=zhangpeng362@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=error27@gmail.com \
--cc=kari.argillander@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=sunnanyong@huawei.com \
--cc=wangkefeng.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).