[PATCH] Fix fd leakage in uki_image_probe()

Pingfan Liu piliu at redhat.com
Mon Nov 4 05:07:44 PST 2024


There is a fd leakage in the fail path when writing to initrd fd in
uki_image_probe(). Fix it by this patch.

Signed-off-by: Pingfan Liu <piliu at redhat.com>
Cc: Simon Horman <horms at kernel.org>
To: kexec at lists.infradead.org
---
 kexec/kexec-uki.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kexec/kexec-uki.c b/kexec/kexec-uki.c
index 202fd89..210ebb6 100644
--- a/kexec/kexec-uki.c
+++ b/kexec/kexec-uki.c
@@ -77,6 +77,7 @@ int uki_image_probe(const char *file_buf, off_t buf_sz)
 					sect_hdr->raw_data_size) != sect_hdr->raw_data_size) {
 				dbgprintf("%s: Can't write the compressed file %s\n",
 						__func__, initrd_fname);
+				close(initrd_fd);
 				goto next;
 			} else {
 				implicit_initrd_fd = open(initrd_fname, O_RDONLY);
-- 
2.41.0




More information about the kexec mailing list