]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
MIPS: fw: Allow firmware to pass a empty env
authorJiaxun Yang <jiaxun.yang@flygoat.com>
Tue, 11 Apr 2023 11:14:26 +0000 (12:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:10:51 +0000 (23:10 +0900)
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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/mips/fw/lib/cmdline.c

index f24cbb4a39b506ad015c15cbd3773b2502b4dc1e..892765b742bbca9ef704f0686e679fb349c5c274 100644 (file)
@@ -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