[PATCH] tools: Fix memory and file descriptor leaks in read_full_file()

Tom Rini trini at konsulko.com
Fri Apr 18 19:54:20 CEST 2025


On Fri, Apr 18, 2025 at 08:19:47PM +0300, ant.v.moryakov at gmail.com wrote:

> From: Maks Mishin <maks.mishinFZ at gmail.com>
> 
> Fixes potential memory and file descriptor leaks in the read_full_file()
> function. If malloc succeeds but read() fails, the buffer was not freed,
> and the file descriptor was not closed. This patch ensures both resources
> are properly released using a common exit point.
> 
> Signed-off-by: Maks Mishin <maks.mishinFZ at gmail.com>
> Signed-off-by: Anton Moryakov <ant.v.moryakov at gmail.com>
> ---
>  tools/zynqmpbif.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)

Please note that this patch is malformed:
patch: **** malformed patch at line 125: @@ -214,24 +215,29 @@ static char *read_full_file(const char *filename, size_t *size)
as it looks like you're hand-editing the patches.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250418/3dafdb3d/attachment.sig>


More information about the U-Boot mailing list