]> git.ipfire.org Git - thirdparty/u-boot.git/commit
tools: fix handle leak in ifdtool.c
authorAnton Moryakov <ant.v.moryakov@gmail.com>
Fri, 16 May 2025 15:25:38 +0000 (18:25 +0300)
committerTom Rini <trini@konsulko.com>
Tue, 3 Jun 2025 23:18:02 +0000 (17:18 -0600)
commita4fb99ce4e6ee62f3278d7472b9b9282d7b289ed
tree5c2a448adb9d3fa3e3a26fcfee9ef521950c5609
parentd786c6b69f537ed2a64950028d270d064970d29f
tools: fix handle leak in ifdtool.c

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@gmail.com>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
tools/ifdtool.c