[PATCH] eventfs: Directly return NULL to avoid null point dereferenced

hao.ge
2024-05-11T02:43:04Z

From: Hao Ge <gehao@kylinos.cn>

When the condition ei->is_free holds,we return NULL directly to
avoid update_events_attr to use NULL point about ei.

Fixes: 8186fff7ab64 ("tracefs/eventfs: Use root and instance inodes as default ownership")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
fs/tracefs/event_inode.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index a878cea70f4c..da2827c6acc2 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -346,8 +346,7 @@ static struct eventfs_inode *eventfs_find_events(struct dentry *dentry)
* doesn't matter.
*/
if (ei->is_freed) {
- ei = NULL;
- break;
+ return NULL;
}
// Walk upwards until you find the events inode
} while (!ei->is_events);
--
2.25.1