[U-Boot-Users] [rfc] warning about overlapping regions when booting with bootm

Mike Frysinger vapier at gentoo.org
Sat Feb 16 08:59:32 CET 2008


we semi-frequently get users who try to boot an image on top of itself and
when when things crash, dont realize why.  i put together this quick little
warning, but i'm guessing that Wolfgang's answer is "don't bloat the code for
stupid people" ...

--- common/cmd_bootm.c
+++ common/cmd_bootm.c
@@ -1434,6 +1439,16 @@ int gunzip(void *dst, int dstlen, unsign
 	z_stream s;
 	int r, i, flags;
 
+	/* If memory regions overlap, whine about it.  We cannot check
+	 * the dstlen value as it is usually set to the max possible value
+	 * (CFG_BOOTM_LEN) which can be huge (64M).  Instead, we'll assume
+	 * the decompression size will be at least as big as the compressed
+	 * size so that we can at least check part of the destination.
+	 */
+	if ((dst <= (void *)src && (void *)src < dst + /*dstlen*/ *lenp) ||
+	    (dst <= (void *)(src + *lenp) && (void *)(src + *lenp) < dst + /*dstlen*/ *lenp))
+		puts ("\n   Warning: src and dst regions overlap ... ");
+
 	/* skip header */
 	i = 10;
 	flags = src[3];
-mike




More information about the U-Boot mailing list