From eaa53a19795f495fb856dc6c03060b2151da26f5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 23 Nov 2020 22:16:07 -0500 Subject: [PATCH] joystick: On Linux, don't try to close an invalid inotify file descriptor. --- src/joystick/linux/SDL_sysjoystick.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 76b83c6e58..7129479748 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -1320,8 +1320,10 @@ LINUX_JoystickQuit(void) SDL_joylist_item *item = NULL; SDL_joylist_item *next = NULL; - close(inotify_fd); - inotify_fd = -1; + if (inotify_fd >= 0) { + close(inotify_fd); + inotify_fd = -1; + } for (item = SDL_joylist; item; item = next) { next = item->next;