From: Pingfan Liu <piliu@redhat.com>
To: kexec@lists.infradead.org
Cc: Pingfan Liu <piliu@redhat.com>, Simon Horman <horms@kernel.org>
Subject: [PATCH] Fix fd leakage in uki_image_probe()
Date: Mon, 4 Nov 2024 21:07:44 +0800 [thread overview]
Message-ID: <20241104130745.18224-1-piliu@redhat.com> (raw)
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@redhat.com>
Cc: Simon Horman <horms@kernel.org>
To: kexec@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
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2024-11-04 13:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 13:07 Pingfan Liu [this message]
2024-11-06 9:28 ` [PATCH] Fix fd leakage in uki_image_probe() Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241104130745.18224-1-piliu@redhat.com \
--to=piliu@redhat.com \
--cc=horms@kernel.org \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox