Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: fw: Allow firmware to pass a empty env

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: https://github.com/clbr/n64bootloader/issues/5
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Jiaxun Yang and committed by
Thomas Bogendoerfer
ee1809ed 7fb6f7b0

+1 -1
+1 -1
arch/mips/fw/lib/cmdline.c
··· 53 53 { 54 54 char *result = NULL; 55 55 56 - if (_fw_envp != NULL) { 56 + if (_fw_envp != NULL && fw_envp(0) != NULL) { 57 57 /* 58 58 * Return a pointer to the given environment variable. 59 59 * YAMON uses "name", "value" pairs, while U-Boot uses