[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/arm: kernel: Propagate the error if we fail to decompress the kernel

commit 27eb6833134d0f3ddfb02d09055776e837e9a747
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Tue Apr 6 20:15:54 2021 +0100
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Mon May 17 17:09:40 2021 +0100

    xen/arm: kernel: Propagate the error if we fail to decompress the kernel
    Currently, we are ignoring any error from perform_gunzip() and replacing
    the compressed kernel with the "uncompressed" kernel.
    If there is a gzip failure, then it means that the output buffer may
    contain garbagge. So it can result to various sort of behavior that may
    be difficult to root cause.
    In case of failure, free the output buffer and propagate the error.
    We also need to adjust the return check for kernel_compress() as
    perform_gunzip() may return a positive value.
    Take the opportunity to adjust the code style for the check.
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
 xen/arch/arm/kernel.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index ab78689ed2..8f43caa186 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -292,6 +292,12 @@ static __init int kernel_decompress(struct bootmodule *mod)
+    if ( rc )
+    {
+        free_domheap_pages(pages, kernel_order_out);
+        return rc;
+    }
     mod->start = page_to_maddr(pages);
     mod->size = output_size;
@@ -503,7 +509,7 @@ int __init kernel_probe(struct kernel_info *info,
     /* if it is a gzip'ed image, 32bit or 64bit, uncompress it */
     rc = kernel_decompress(mod);
-    if (rc < 0 && rc != -EINVAL)
+    if ( rc && rc != -EINVAL )
         return rc;
 #ifdef CONFIG_ARM_64
generated by git-patchbot for /home/xen/git/xen.git#master



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.