ns16550: harden name/value pair parsing

strsep(), unless passed a 1st argument which itself points at a NULL
pointer, won't return NULL. Instead if the separator(s) looked for isn't
found, that pointed-to field would be updated to hold NULL. Hence the
important check in get_token() is for token to be non-NULL after the call
(which get_token()'s callers rely upon), while the checking of param_name
is left there just in case.

Fixes: 97fd49a7e0 ("ns16550: add support for UART parameters to be specifed with name-value pairs")
Reported-by: Kamil Frankowicz <kamil.frankowicz@cert.pl>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: b27d3b45c7
master date: 2026-04-07 13:53:49 +0200
This commit is contained in:
Jan Beulich committed 2026-04-20 12:26:09 +02:00
1 parent c9ba169b93
commit f35f0ac0c8
1 file changed
+1 -1
+1 -1
View File
@@ -1472,7 +1472,7 @@ static enum __init serial_param_type get_token(char *token, char **value)
unsigned int i;
param_name = strsep(&token, "=");
if ( param_name == NULL )
if ( !param_name || !token )
return num_serial_params;
/* Linear search for the parameter. */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.