From d54c1e6c448f538d513eda1abe397b3575b9b8df Mon Sep 17 00:00:00 2001 From: Spiky Caterpillar Date: Wed, 16 Nov 2022 23:18:44 +0000 Subject: [PATCH] No longer leak FDs on VT switch. Modified-by: Povilas Kanapickas Part-of: (cherry picked from commit 2631cad85db59ec19cce5ce0df2e7434ba214cee) --- hw/xfree86/os-support/linux/systemd-logind.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c index c6a24fc7b..3254b2ce3 100644 --- a/hw/xfree86/os-support/linux/systemd-logind.c +++ b/hw/xfree86/os-support/linux/systemd-logind.c @@ -397,6 +397,11 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data) dbus_error_free(&error); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } + + /* + * fd will be received via DBus if and only if pause == 0, so it + * only needs to be closed in that code path + */ } else return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -431,6 +436,7 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data) info->active = TRUE; if (pdev) { + close(fd); pdev->flags &= ~XF86_PDEV_PAUSED; } else systemd_logind_set_input_fd_for_all_devs(major, minor, fd,