From f3ca3aa16b15d63f74ea60ca5a4a83da65d9b215 Mon Sep 17 00:00:00 2001 From: Bill XIE Date: Wed, 4 Jun 2025 10:04:54 +0800 Subject: [PATCH] util/cbfstool/cbfs-payload-linux: Copy segments when compression fails When compression fails (usually due to larger result), we could retry with memcpy() as in cbfs-mkpayload.c, instead of stopping immediately. Signed-off-by: Bill XIE Change-Id: Id8b2cffef3832c4bad49bd722c9a5133735f61b0 Reviewed-on: https://review.coreboot.org/c/coreboot/+/87934 Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- util/cbfstool/cbfs-payload-linux.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/cbfstool/cbfs-payload-linux.c b/util/cbfstool/cbfs-payload-linux.c index d0f24fec6c..0eb841df82 100644 --- a/util/cbfstool/cbfs-payload-linux.c +++ b/util/cbfstool/cbfs-payload-linux.c @@ -163,10 +163,12 @@ static int bzp_output_segment(struct bzpayload *bzp, struct buffer *b, seg->offset = bzp->offset; comp_func_ptr compress_func = compression_function(algo); - int ret = compress_func(buffer_get(b), buffer_size(b), buffer_get(&out), &len); - if (ret) { - ERROR("%s(): Compression failed\n", __func__); - return ret; + if (compress_func(buffer_get(b), buffer_size(b), buffer_get(&out), &len)) { + WARN("Compression failed or would make the data bigger " + "- disabled.\n"); + algo = CBFS_COMPRESS_NONE; + len = buffer_size(b); + memcpy(buffer_get(&out), buffer_get(b), len); } seg->compression = algo;