summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiaxun Yang <jiaxun.yang@flygoat.com>2023-04-11 14:14:26 +0300
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>2023-04-12 16:07:36 +0300
commitee1809ed7bc456a72dc8410b475b73021a3a68d5 (patch)
tree2332247e9e0986d219a99a0067bb4bf8f5ed9cc2
parent7fb6f7b0af6742601e0efe315c78c26e88d30ff1 (diff)
downloadlinux-ee1809ed7bc456a72dc8410b475b73021a3a68d5.tar.xz
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>
-rw-r--r--arch/mips/fw/lib/cmdline.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/mips/fw/lib/cmdline.c b/arch/mips/fw/lib/cmdline.c
index f24cbb4a39b5..892765b742bb 100644
--- a/arch/mips/fw/lib/cmdline.c
+++ b/arch/mips/fw/lib/cmdline.c
@@ -53,7 +53,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