[OpenBIOS] [PATCH 3/7] SPARC64: fix NULL pointer reference when attempting kernel boot

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Sun May 4 19:49:51 CEST 2014


When checking to determine whether to boot a standalone kernel, we would
inadvertently reference a NULL pointer if no path was found. Make sure
subsequent path processing is ignored when not booting a standalone kernel
so we fall through to normal Forth boot.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/arch/sparc64/boot.c |   40 +++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/openbios-devel/arch/sparc64/boot.c b/openbios-devel/arch/sparc64/boot.c
index c4e40b0..5107be6 100644
--- a/openbios-devel/arch/sparc64/boot.c
+++ b/openbios-devel/arch/sparc64/boot.c
@@ -105,24 +105,26 @@ void boot(void)
             path = pop_fstr_copy();
 	}
 
-	param = strchr(path, ' ');
-	if(param) {
-		*param = '\0';
-		param++;
-	} else if (cmdline_size) {
-            param = (char *)qemu_cmdline;
-        } else {
-            push_str("boot-args");
-            push_str("/options");
-            fword("(find-dev)");
-            POP();
-            fword("get-package-property");
-            POP();
-            param = pop_fstr_copy();
+        if (path) {
+            param = strchr(path, ' ');
+            if(param) {
+                *param = '\0';
+                param++;
+            } else if (cmdline_size) {
+                param = (char *)qemu_cmdline;
+            } else {
+                push_str("boot-args");
+                push_str("/options");
+                fword("(find-dev)");
+                POP();
+                fword("get-package-property");
+                POP();
+                param = pop_fstr_copy();
+            }
+
+            /* Invoke platform-specific Linux loader */
+            linux_load(&sys_info, path, param);
+
+            free(path);
         }
-	
-	/* Invoke platform-specific Linux loader */
-	linux_load(&sys_info, path, param);
-
-	free(path);
 }
-- 
1.7.10.4




More information about the OpenBIOS mailing list