diff --git a/src/sysinput.c b/src/sysinput.c index ebc0ae5..788547e 100644 --- a/src/sysinput.c +++ b/src/sysinput.c @@ -176,9 +176,8 @@ HRESULT Sys_enable_input(void) if (ts_fd < 0) { rc = ERRNO_AS_SCODE; - Mq_destroy(Sys_Queue); Log(LFATAL, "Unable to open touchscreen device %s (%08X).", Gconfig.touchscreen_device, rc); - return rc; + goto error_0; } running = 1; @@ -186,20 +185,20 @@ HRESULT Sys_enable_input(void) if (threadrc != 0) { rc = SCODE_FROM_ERRNO(threadrc); - close(ts_fd); - ts_fd = -1; - Mq_destroy(Sys_Queue); Log(LFATAL, "Unable to start system input thread (%08X).", rc); + goto error_1; } - if (SUCCEEDED(rc)) - { - rc = Config_exitfunc(do_disable_input); - if (FAILED(rc)) - do_disable_input(); - } - return rc; + rc = Config_exitfunc(do_disable_input); + if (FAILED(rc)) + do_disable_input(); + return rc; + +error_1: + close(ts_fd); + ts_fd = -1; error_0: + Mq_destroy(Sys_Queue); return rc; }