[PATCH 1/2] MIPS: rtlx: Drop in_open count when rtlx_init() fails

From: Suyuan Wang via B4 Relay

Date: Sat Nov 21 2026 - 10:33:08 EST


From: Suyuan Wang <stevewong@xxxxxxxxxxx>

rtlx_open() raises channel_wqs[index].in_open at the start and drops it
again at out_fail, on both the success and the error paths. When
rtlx_init() fails, for example because the SP program has no valid RTLX
id, the code jumps to out_ret instead and skips the decrement.

After that, every later open of the channel sees in_open > 1 and fails
with -EBUSY, even after a correct SP program is loaded.

Jump to out_fail so the count is dropped, and remove the now unused
out_ret label.

Found with a static analysis tool and checked by hand.

Fixes: c4c4018b04f9 ("[MIPS] RTLX, VPE: Make open actually atomic.")
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 | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 18c509c59f33..a1da56163f19 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -159,7 +159,7 @@ int rtlx_open(int index, int can_sleep)

ret = rtlx_init(*p);
if (ret < 0)
- goto out_ret;
+ goto out_fail;
}

chan = &rtlx->channel[index];
@@ -175,7 +175,6 @@ int rtlx_open(int index, int can_sleep)
atomic_dec(&channel_wqs[index].in_open);
smp_mb();

-out_ret:
return ret;
}


--
2.34.1