On Sun, Feb 09, 2025 at 05:56:41PM +0300, Maks Mishin wrote:

> The handle 'ptr' is created at fit_common.c:91 by calling 
> function 'mmap' and lost at fit_common.c:127: 
> Added call of free for `ptr` if ptr != MAP_FAILED.
> 
> Trigger was found by the Svace static analyzer.
> 
> Signed-off-by: Maks Mishin <maks.mishi...@gmail.com>
> ---
>  tools/fit_common.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/fit_common.c b/tools/fit_common.c
> index d1cde16c1c..135e105929 100644
> --- a/tools/fit_common.c
> +++ b/tools/fit_common.c
> @@ -123,6 +123,7 @@ err:
>               close(fd);
>       if (delete_on_error)
>               unlink(fname);
> +     free(ptr);
>  
>       return -1;
>  }

This introduces:
/home/uboot/u-boot/u-boot/tools/fit_common.c: In function 'mmap_fdt':
/home/uboot/u-boot/u-boot/tools/fit_common.c:126:9: warning: 'ptr' may be used 
uninitialized in
 this function [-Wmaybe-uninitialized]
  126 |         free(ptr);
      |         ^~~~~~~~~

-- 
Tom

Attachment: signature.asc
Description: PGP signature

Reply via email to