[PATCH 2/2] MIPS: rtlx: Call finish_wait() when rtlx_open() is interrupted
From: Suyuan Wang via B4 Relay
Date: Sat Nov 21 2026 - 10:33:10 EST
From: Suyuan Wang <stevewong@xxxxxxxxxxx>
While rtlx_open() waits for the SP program, it calls prepare_to_wait()
with a wait entry on its own stack. If a signal is pending, it leaves
the loop with:
ret = -ERESTARTSYS;
goto out_fail;
and skips finish_wait(). The stack wait entry stays on
channel_wqs[index].lx_queue after rtlx_open() returns, and the task is
still in TASK_INTERRUPTIBLE state. A later wake up of that queue then
walks a stale stack entry.
Call finish_wait() before leaving the loop on a signal.
Found with a static analysis tool and checked by hand.
Fixes: 9e3468202657 ("[MIPS] RTLX: Don't use volatile; it's fragile.")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Suyuan Wang <stevewong@xxxxxxxxxxx>
---
arch/mips/kernel/rtlx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index a1da56163f19..d5ea99bde129 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -138,6 +138,8 @@ int rtlx_open(int index, int can_sleep)
schedule();
continue;
}
+ finish_wait(&channel_wqs[index].lx_queue,
+ &wait);
ret = -ERESTARTSYS;
goto out_fail;
}
--
2.34.1