From 8bfd38d6cac876f860e5dbf663b3b6db53e6423c Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Fri, 12 Sep 2014 10:01:24 +0200 Subject: [PATCH] module-mmkbd-evdev: Don't crash on failure to close fd If the keyboard is unplugged, it looks like the kernel is reporting back -ENODEV when trying to close the fd. This is probably a kernel error, but still, it's better to complain than to crash. Buglink: https://bugs.freedesktop.org/show_bug.cgi?id=80867 Reported-by: Stelios Bounanos Signed-off-by: David Henningsson --- src/modules/module-mmkbd-evdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c index 9ab7eb973..0b04f0f9c 100644 --- a/src/modules/module-mmkbd-evdev.c +++ b/src/modules/module-mmkbd-evdev.c @@ -256,8 +256,11 @@ void pa__done(pa_module*m) { if (u->io) m->core->mainloop->io_free(u->io); - if (u->fd >= 0) - pa_assert_se(pa_close(u->fd) == 0); + if (u->fd >= 0) { + int r = pa_close(u->fd); + if (r < 0) /* https://bugs.freedesktop.org/show_bug.cgi?id=80867 */ + pa_log("Closing fd failed: %s", pa_cstrerror(errno)); + } pa_xfree(u->sink_name); pa_xfree(u);