]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
ui/input-linux: close evdev fd when qemu_set_blocking fails
authorGuoHan Zhao <zhaoguohan@kylinos.cn>
Wed, 8 Apr 2026 02:40:24 +0000 (10:40 +0800)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 22 Apr 2026 08:36:59 +0000 (12:36 +0400)
input_linux_complete() opens the evdev node before switching it to
non-blocking mode. If qemu_set_blocking() fails, the function returns
without closing the file descriptor.

The finalize path only closes initialized devices, so this leaks the fd
on an error path.

Jump to err_close when qemu_set_blocking() fails so the descriptor is
released before returning.

Fixes: c7b1172026a0 ("ui: replace qemu_set_nonblock()")
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260408024024.606222-1-zhaoguohan@kylinos.cn>

ui/input-linux.c

index c16726a3b799131adda6ff5bc49fa0741f4efcb8..74bc8511428a420790301c6ad999cb8c1762de90 100644 (file)
@@ -316,7 +316,7 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
         return;
     }
     if (!qemu_set_blocking(il->fd, false, errp)) {
-        return;
+        goto err_close;
     }
 
     rc = ioctl(il->fd, EVIOCGVERSION, &ver);