summaryrefslogtreecommitdiff
path: root/lib/fdtdec.c
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@gmail.com>2019-03-13 21:11:22 +0100
committerMarek Vasut <marex@denx.de>2019-04-09 18:19:10 +0200
commit1fd303543aef9c4641bd578e6e52284f5a69df67 (patch)
tree7414df865084303c36cd9e4451b0b963b449eb12 /lib/fdtdec.c
parent4fa8375ffec5bd1c7edabde42b8ee0339072df38 (diff)
lib: fdt: Allow enabling both LZO and GZIP DT compression
Allow enabling both LZO and GZIP DT compression in SPL and fix a bug where if the GZIP decompression failed, the LZO decompression would not even be attempted. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r--lib/fdtdec.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 79915b59bd..d5e8b5a420 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1183,16 +1183,21 @@ int fdtdec_setup_memory_banksize(void)
static int uncompress_blob(const void *src, ulong sz_src, void **dstp)
{
size_t sz_out = CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ;
+ bool gzip = 0, lzo = 0;
ulong sz_in = sz_src;
void *dst;
int rc;
if (CONFIG_IS_ENABLED(GZIP))
- if (gzip_parse_header(src, sz_in) < 0)
- return -1;
+ if (gzip_parse_header(src, sz_in) >= 0)
+ gzip = 1;
if (CONFIG_IS_ENABLED(LZO))
- if (!lzop_is_valid_header(src))
- return -EBADMSG;
+ if (!gzip && lzop_is_valid_header(src))
+ lzo = 1;
+
+ if (!gzip && !lzo)
+ return -EBADMSG;
+
if (CONFIG_IS_ENABLED(MULTI_DTB_FIT_DYN_ALLOC)) {
dst = malloc(sz_out);
@@ -1208,10 +1213,12 @@ static int uncompress_blob(const void *src, ulong sz_src, void **dstp)
# endif
}
- if (CONFIG_IS_ENABLED(GZIP))
+ if (CONFIG_IS_ENABLED(GZIP) && gzip)
rc = gunzip(dst, sz_out, (u8 *)src, &sz_in);
- else if (CONFIG_IS_ENABLED(LZO))
+ else if (CONFIG_IS_ENABLED(LZO) && lzo)
rc = lzop_decompress(src, sz_in, dst, &sz_out);
+ else
+ hang();
if (rc < 0) {
/* not a valid compressed blob */