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 <david.henningsson@canonical.com>
This commit is contained in:
David Henningsson 2014-09-12 10:01:24 +02:00
parent f04e31dc5e
commit 8bfd38d6ca

View file

@ -256,8 +256,11 @@ void pa__done(pa_module*m) {
if (u->io) if (u->io)
m->core->mainloop->io_free(u->io); m->core->mainloop->io_free(u->io);
if (u->fd >= 0) if (u->fd >= 0) {
pa_assert_se(pa_close(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->sink_name);
pa_xfree(u); pa_xfree(u);