[PATCH] tools: fix handle leak in ifdtool.c

Quentin Schulz quentin.schulz at cherry.de
Mon May 19 10:47:25 CEST 2025


Hi Anton,

On 5/16/25 5:25 PM, ant.v.moryakov at gmail.com wrote:
> From: Anton Moryakov <ant.v.moryakov at gmail.com>
> 
> Prevent file descriptor leaks by properly closing 'fd' and 'new_fd'
> when fstat() or write() operations fail.
> 
> - Added close(fd) before return in open_for_read() if fstat() fails.
> - Added close(new_fd) before return in write_image() if write() fails.
> - No close needed if open() fails (fd == -1 is invalid).
> 
> Signed-off-by: Anton Moryakov <ant.v.moryakov at gmail.com>

Looks fine to me

Reviewed-by: Quentin Schulz <quentin.schulz at cherry.de>

I believe there are a few others in that file?

inject_region returns without closing, same for write_data, same for the 
main function with bios_fd at the very least.

Thanks!
Quentin


More information about the U-Boot mailing list