]> git.ipfire.org Git - thirdparty/linux.git/commit
tools/bootconfig: fix fd leak in load_xbc_file() on fstat failure
authorJosh Law <objecting@objecting.org>
Wed, 18 Mar 2026 23:43:06 +0000 (08:43 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 18 Mar 2026 23:43:06 +0000 (08:43 +0900)
commit3b2c2ab4ceb82af484310c3087541eab00ea288b
tree0afd22923d8d920d8cffc69ba16abc5191b033f0
parentbb288d7d869e86d382f35a0e26242c5ccb05ca82
tools/bootconfig: fix fd leak in load_xbc_file() on fstat failure

If fstat() fails after open() succeeds, the function returns without
closing the file descriptor. Also preserve errno across close(), since
close() may overwrite it before the error is returned.

Link: https://lore.kernel.org/all/20260318155847.78065-3-objecting@objecting.org/
Fixes: 950313ebf79c ("tools: bootconfig: Add bootconfig command")
Signed-off-by: Josh Law <objecting@objecting.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
tools/bootconfig/main.c