* [PATCH] dump:Add close fd on error return to avoid resource leak
@ 2023-11-07 2:44 Zongmin Zhou
2023-11-07 6:15 ` Marc-André Lureau
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Zongmin Zhou @ 2023-11-07 2:44 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel; +Cc: Zongmin Zhou, Zongmin Zhou
Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
---
dump/dump.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dump/dump.c b/dump/dump.c
index 1c304cadfd..ad5294e853 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -2160,6 +2160,7 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
return;
}
if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
+ close(fd);
error_setg(errp, "kdump-raw formats require a seekable file");
return;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] dump:Add close fd on error return to avoid resource leak
2023-11-07 2:44 [PATCH] dump:Add close fd on error return to avoid resource leak Zongmin Zhou
@ 2023-11-07 6:15 ` Marc-André Lureau
2023-11-07 8:55 ` Philippe Mathieu-Daudé
2023-11-07 11:48 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 5+ messages in thread
From: Marc-André Lureau @ 2023-11-07 6:15 UTC (permalink / raw)
To: Zongmin Zhou; +Cc: qemu-devel, Zongmin Zhou
On Tue, Nov 7, 2023 at 10:07 AM Zongmin Zhou <min_halo@163.com> wrote:
>
> Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> dump/dump.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index 1c304cadfd..ad5294e853 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -2160,6 +2160,7 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
> return;
> }
> if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
> + close(fd);
> error_setg(errp, "kdump-raw formats require a seekable file");
> return;
> }
> --
> 2.34.1
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dump:Add close fd on error return to avoid resource leak
2023-11-07 2:44 [PATCH] dump:Add close fd on error return to avoid resource leak Zongmin Zhou
2023-11-07 6:15 ` Marc-André Lureau
@ 2023-11-07 8:55 ` Philippe Mathieu-Daudé
2023-11-07 11:48 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-07 8:55 UTC (permalink / raw)
To: Zongmin Zhou, marcandre.lureau, qemu-devel, Stephen Brennan; +Cc: Zongmin Zhou
On 7/11/23 03:44, Zongmin Zhou wrote:
> Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
Reported-by: Coverity CID 1523842 (RESOURCE_LEAK)
Fixes: e6549197f7 ("dump: Add command interface for kdump-raw formats")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> dump/dump.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index 1c304cadfd..ad5294e853 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -2160,6 +2160,7 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
> return;
> }
> if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
> + close(fd);
> error_setg(errp, "kdump-raw formats require a seekable file");
> return;
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dump:Add close fd on error return to avoid resource leak
2023-11-07 2:44 [PATCH] dump:Add close fd on error return to avoid resource leak Zongmin Zhou
2023-11-07 6:15 ` Marc-André Lureau
2023-11-07 8:55 ` Philippe Mathieu-Daudé
@ 2023-11-07 11:48 ` Philippe Mathieu-Daudé
2023-11-07 11:54 ` Marc-André Lureau
2 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-07 11:48 UTC (permalink / raw)
To: Zongmin Zhou, marcandre.lureau, qemu-devel; +Cc: Zongmin Zhou
On 7/11/23 03:44, Zongmin Zhou wrote:
> Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
> ---
> dump/dump.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index 1c304cadfd..ad5294e853 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -2160,6 +2160,7 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
> return;
> }
> if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
> + close(fd);
> error_setg(errp, "kdump-raw formats require a seekable file");
> return;
> }
Since I'm preparing a PR, I'm queuing this patch, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dump:Add close fd on error return to avoid resource leak
2023-11-07 11:48 ` Philippe Mathieu-Daudé
@ 2023-11-07 11:54 ` Marc-André Lureau
0 siblings, 0 replies; 5+ messages in thread
From: Marc-André Lureau @ 2023-11-07 11:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: Zongmin Zhou, qemu-devel, Zongmin Zhou
On Tue, Nov 7, 2023 at 3:48 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 7/11/23 03:44, Zongmin Zhou wrote:
> > Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
> > ---
> > dump/dump.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/dump/dump.c b/dump/dump.c
> > index 1c304cadfd..ad5294e853 100644
> > --- a/dump/dump.c
> > +++ b/dump/dump.c
> > @@ -2160,6 +2160,7 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
> > return;
> > }
> > if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) {
> > + close(fd);
> > error_setg(errp, "kdump-raw formats require a seekable file");
> > return;
> > }
>
> Since I'm preparing a PR, I'm queuing this patch, thanks!
>
ack, thanks
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-07 11:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-07 2:44 [PATCH] dump:Add close fd on error return to avoid resource leak Zongmin Zhou
2023-11-07 6:15 ` Marc-André Lureau
2023-11-07 8:55 ` Philippe Mathieu-Daudé
2023-11-07 11:48 ` Philippe Mathieu-Daudé
2023-11-07 11:54 ` Marc-André Lureau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).