On Thu, Oct 8, 2009 at 2:49 PM, Myles Watson <[email protected]> wrote:
> Move the ulzma prototype into cbfs.h
> Check the return value when decompressing.

With the patch.
Signed-off-by: Myles Watson <[email protected]>

> It's not 100% fixed, since the caller (cbfs_load_stage)
>
>        if (cbfs_decompress(stage->compression,
>                             ((unsigned char *) stage) +
>                             sizeof(struct cbfs_stage),
>                             (void *) (u32) stage->load,
>                             stage->len))
>                return (void *) -1;
>
> returns -1 and then cbfs_and_run_core jumps to it.
>
> print_debug("Jumping to image.\r\n");
> dst = cbfs_load_stage(filename);
> print_debug("Jumping to image.\r\n");
>
> Why do we jump to a -1 instead of hanging?
>
> Thanks,
> Myles
>
Index: svn/src/lib/cbfs.c
===================================================================
--- svn.orig/src/lib/cbfs.c
+++ svn/src/lib/cbfs.c
@@ -36,15 +36,15 @@ int cbfs_decompress(int algo, void *src,
 		memcpy(dst, src, len);
 		return 0;
 
-	case CBFS_COMPRESS_LZMA: {
-		unsigned long ulzma(unsigned char *src, unsigned char *dst);
-		ulzma(src, dst);
-	}
+	case CBFS_COMPRESS_LZMA:
+		if (!ulzma(src, dst)) {
+			printk_err("CBFS: ulzma returned 0!\n");
+			return -1;
+		}
 		return 0;
 
 	default:
-		printk_info( "CBFS:  Unknown compression type %d\n",
-		       algo);
+		printk_info( "CBFS:  Unknown compression type %d\n", algo);
 		return -1;
 	}
 }
Index: svn/src/include/cbfs.h
===================================================================
--- svn.orig/src/include/cbfs.h
+++ svn/src/include/cbfs.h
@@ -50,14 +50,17 @@
 #define _CBFS_H_
 
 #include <boot/coreboot_tables.h>
+
 /** These are standard values for the known compression
     alogrithms that coreboot knows about for stages and
-    payloads.  Of course, other LAR users can use whatever
+    payloads.  Of course, other CBFS users can use whatever
     values they want, as long as they understand them. */
 
 #define CBFS_COMPRESS_NONE  0
 #define CBFS_COMPRESS_LZMA  1
 
+unsigned long ulzma(unsigned char *src, unsigned char *dst);
+
 /** These are standard component types for well known
     components (i.e - those that coreboot needs to consume.
     Users are welcome to use any other value for their
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to