Re: [PATCH 4/4] arm64: Fix some issues with zImage _probe()

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

 



On Fri, May 5, 2023 at 12:44 AM Jeremy Linton <jeremy.linton@xxxxxxx> wrote:
>
> Current compilers note that fname will be null while
> attempting to print failures from strdup().
>
> Further fix a memory leak caused by kernel_uncompressed_buf
> never being used/freed before the allocated block is replaced
> by the one returned by slurp_decompress_file().
>
> Signed-off-by: Jeremy Linton <jeremy.linton@xxxxxxx>
> ---
>  kexec/arch/arm64/kexec-zImage-arm64.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/kexec/arch/arm64/kexec-zImage-arm64.c b/kexec/arch/arm64/kexec-zImage-arm64.c
> index 6ee82ff..3eb1ad8 100644
> --- a/kexec/arch/arm64/kexec-zImage-arm64.c
> +++ b/kexec/arch/arm64/kexec-zImage-arm64.c
> @@ -55,8 +55,7 @@ int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size)
>         }
>
>         if (!(fname = strdup(FILENAME_IMAGE))) {
> -               dbgprintf("%s: Can't duplicate strings %s\n", __func__,
> -                               fname);
> +               dbgprintf("%s: Can't duplicate strings\n", __func__);
>                 return -1;
>         }
>
> @@ -67,15 +66,6 @@ int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size)
>                 goto fail_mkstemp;
>         }
>
> -       kernel_uncompressed_buf =
> -               (char *) calloc(kernel_size, sizeof(off_t));
> -       if (!kernel_uncompressed_buf) {
> -               dbgprintf("%s: Can't calloc %ld bytes\n",
> -                               __func__, kernel_size);
> -               ret= -ENOMEM;
> -               goto fail_calloc;
> -       }
> -
>         /* slurp in the input kernel */
>         dbgprintf("%s: ", __func__);
>         kernel_uncompressed_buf = slurp_decompress_file(kernel_buf,
> @@ -128,7 +118,6 @@ int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size)
>  fail_bad_header:
>         free(kernel_uncompressed_buf);
>
> -fail_calloc:
>         if (fd >= 0)
>                 close(fd);
>
> --
> 2.40.0
>
Reviewed-by: Pingfan Liu <piliu@xxxxxxxxxx>


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux