]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:08:57 +0000 (11:08 +0100)
commitebf6449effd947099e17efdc2ad1b37e1260c1cc
treed994311fc976fef5b01a445657063bc6d27d5ec5
parent21156d04549d5da2830165fe2ce6a8d8ba53981b
tools/bootconfig: fix fd leak in load_xbc_file() on fstat failure

[ Upstream commit 3b2c2ab4ceb82af484310c3087541eab00ea288b ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/bootconfig/main.c