chardev/char-file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
'in' will be -1 when file->in is unset. Let's not try to close
invalid fd.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Coverity: CID 1630444
Fixes: 69620c091d62f "chardev: qemu_chr_open_fd(): add errp"
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
I was going to send it inside v3 of "chardev: postpone connect", but it
seems the discussion may continue there, so, decided to send this small
fix in separate.
chardev/char-file.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/chardev/char-file.c b/chardev/char-file.c
index 89e9cb849c..1f7adf592f 100644
--- a/chardev/char-file.c
+++ b/chardev/char-file.c
@@ -94,7 +94,9 @@ static void qmp_chardev_open_file(Chardev *chr,
if (!qemu_chr_open_fd(chr, in, out, errp)) {
qemu_close(out);
- qemu_close(in);
+ if (in >= 0) {
+ qemu_close(in);
+ }
return;
}
#endif
--
2.48.1
On Tue, Oct 14, 2025 at 6:51 PM Vladimir Sementsov-Ogievskiy
<vsementsov@yandex-team.ru> wrote:
>
> 'in' will be -1 when file->in is unset. Let's not try to close
> invalid fd.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Coverity: CID 1630444
> Fixes: 69620c091d62f "chardev: qemu_chr_open_fd(): add errp"
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>
> I was going to send it inside v3 of "chardev: postpone connect", but it
> seems the discussion may continue there, so, decided to send this small
> fix in separate.
>
> chardev/char-file.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/chardev/char-file.c b/chardev/char-file.c
> index 89e9cb849c..1f7adf592f 100644
> --- a/chardev/char-file.c
> +++ b/chardev/char-file.c
> @@ -94,7 +94,9 @@ static void qmp_chardev_open_file(Chardev *chr,
>
> if (!qemu_chr_open_fd(chr, in, out, errp)) {
> qemu_close(out);
> - qemu_close(in);
> + if (in >= 0) {
> + qemu_close(in);
> + }
> return;
> }
> #endif
> --
> 2.48.1
>
>
--
Marc-André Lureau
On 14.10.25 17:53, Marc-André Lureau wrote: > On Tue, Oct 14, 2025 at 6:51 PM Vladimir Sementsov-Ogievskiy > <vsementsov@yandex-team.ru> wrote: >> 'in' will be -1 when file->in is unset. Let's not try to close >> invalid fd. >> >> Reported-by: Peter Maydell<peter.maydell@linaro.org> >> Coverity: CID 1630444 >> Fixes: 69620c091d62f "chardev: qemu_chr_open_fd(): add errp" >> Signed-off-by: Vladimir Sementsov-Ogievskiy<vsementsov@yandex-team.ru> > Reviewed-by: Marc-André Lureau<marcandre.lureau@redhat.com> Hi, isn't it lost? It's still not in master.. Or did you queued already? -- Best regards, Vladimir
© 2016 - 2025 Red Hat, Inc.