rtos: fix bug in error handling