diff mbox series

eventfs: Directly return NULL to avoid null point dereferenced

Message ID 20240511024255.34767-1-hao.ge@linux.dev (mailing list archive)
State New
Headers show
Series eventfs: Directly return NULL to avoid null point dereferenced | expand

Commit Message

Hao Ge May 11, 2024, 2:42 a.m. UTC
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(-)

Comments

Markus Elfring May 12, 2024, 5:12 p.m. UTC | #1
> When the condition ei->is_free holds,we return NULL directly to
> avoid update_events_attr to use NULL point about ei.

* Please avoid typos in the summary phrase and the commit message.

* Would you like to use an imperative wording for an improved change description?
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc7#n94


…
> +++ 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;
>  		}
…

How do you think about to omit curly brackets here?

Regards,
Markus
Hao Ge May 13, 2024, 3:25 a.m. UTC | #2
Hi Markus


Thanks for your review.


在 5/13/24 01:12, Markus Elfring 写道:
>> When the condition ei->is_free holds,we return NULL directly to
>> avoid update_events_attr to use NULL point about ei.
> * Please avoid typos in the summary phrase and the commit message.
>
> * Would you like to use an imperative wording for an improved change description?
>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc7#n94
>
>
> …
OK, I'll study it,
>> +++ 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;
>>   		}
> …
>
> How do you think about to omit curly brackets here?
You are right, I will make changes to it in future versions
>
> Regards,
> Markus

Best Regards

Hao
diff mbox series

Patch

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);