[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240222102548.1426561-1-suhui@nfschina.com>
Date: Thu, 22 Feb 2024 18:25:49 +0800
From: Su Hui <suhui@...china.com>
To: hubcap@...ibond.com,
martin@...ibond.com
Cc: Su Hui <suhui@...china.com>,
xiyuyang19@...an.edu.cn,
cymi20@...an.edu.cn,
tanxin.ctf@...il.com,
devel@...ts.orangefs.org,
linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH] orangefs: Fix possible NULL deference in orangefs_mount
scripts/coccinelle/null/deref_null.cocci complains:
fs/orangefs/super.c:584:18-25: ERROR:
ORANGEFS_SB ( sb ) is NULL but dereferenced.
When memory allocation for orangefs_sb_info_s fails, ORANGEFS_SB(sb)
is NULL and ORANGEFS_SB(sb)->no_list will result in NULL deference.
Add a judgement to fix this NULL deference problem.
Fixes: ac2c63757f4f ("orangefs: Fix sb refcount leak when allocate sb info failed.")
Signed-off-by: Su Hui <suhui@...china.com>
---
fs/orangefs/super.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index 5254256a224d..c056c86e2482 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -581,7 +581,8 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
free_sb_and_op:
/* Will call orangefs_kill_sb with sb not in list. */
- ORANGEFS_SB(sb)->no_list = 1;
+ if (ORANGEFS_SB(sb))
+ ORANGEFS_SB(sb)->no_list = 1;
/* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */
deactivate_locked_super(sb);
free_op:
--
2.30.2
Powered by blists - more mailing lists