From: Vladimir Sementsov-Ogievskiy <[email protected]> '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]> Reviewed-by: Marc-André Lureau <[email protected]> Message-ID: <[email protected]> --- 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.51.1
