Skip to content

Commit

Permalink
MIPS: fw: Allow firmware to pass a empty env
Browse files Browse the repository at this point in the history
commit ee1809ed7bc456a72dc8410b475b73021a3a68d5 upstream.

fw_getenv will use env entry to determine style of env,
however it is legal for firmware to just pass a empty list.

Check if first entry exist before running strchr to avoid
null pointer dereference.

Cc: stable@vger.kernel.org
Link: clbr/n64bootloader#5
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Santhosh <santhosh.user.why.red@gmail.com>
  • Loading branch information
FlyGoat authored and Sorayukii committed Oct 27, 2024
1 parent a95682c commit 9605c61
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/mips/fw/lib/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ char *fw_getenv(char *envname)
{
char *result = NULL;

if (_fw_envp != NULL) {
if (_fw_envp != NULL && fw_envp(0) != NULL) {
/*
* Return a pointer to the given environment variable.
* YAMON uses "name", "value" pairs, while U-Boot uses
Expand Down

0 comments on commit 9605c61

Please sign in to comment.