ping

On 14.10.25 17:50, Vladimir Sementsov-Ogievskiy wrote:
'in' will be -1 when file->in is unset. Let's not try to close
invalid fd.

Reported-by: Peter Maydell <[email protected]>
Coverity: CID 1630444
Fixes: 69620c091d62f "chardev: qemu_chr_open_fd(): add errp"
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
---

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


--
Best regards,
Vladimir

Reply via email to