user_events: Fix potential uninitialized pointer while parsing field
PATCH 1/1 user_events: Fix potential uninitialized pointer while parsing field
Ensure name is initialized by default to NULL to prevent possible edge cases that could lead to it being left uninitialized. Add an explicit check for NULL name to ensure edge boundaries.
Signed-off-by Beau Belgrave <[email protected]>
Reported-by Dan Carpenter <[email protected]>
--- kernel/trace/trace_events_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace_events_user.c +3 -1
@@ -362,6 +362,8 @@ static int user_event_parse_field(char *field, struct user_event *user, *field++ ='\0' ; depth++; parse: + name =NULL ; +while ((part =strsep (&field," " )) !=NULL ) {switch (depth++) {case FIELD_DEPTH_TYPE :
@@ -382,7 +384,7 @@ static int user_event_parse_field(char *field, struct user_event *user, } } -if (depth <FIELD_DEPTH_SIZE ) +if (depth <FIELD_DEPTH_SIZE || !name)return -EINVAL ;if (depth ==FIELD_DEPTH_SIZE )
base-commit: 864ea0e10cc90416a01b46f0d47a6f26dc020820
Signature · 1 line
2.17.1