mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: tsbogend@alpha.franken.de
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] MIPS: rtlx: Drop in_open count when rtlx_init() fails
Date: Sat, 21 Nov 2026 15:33:01 +0000	[thread overview]
Message-ID: <20261121-rtlx-v1-1-bc05d6763ec1@gmail.com> (raw)
In-Reply-To: <20261121-rtlx-v1-0-bc05d6763ec1@gmail.com>

From: Suyuan Wang <stevewong@hust.edu.cn>

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@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
 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



  reply	other threads:[~2026-11-21 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 15:33 [PATCH 0/2] MIPS: rtlx: Fix two error paths in rtlx_open() Suyuan Wang via B4 Relay
2026-11-21 15:33 ` Suyuan Wang via B4 Relay [this message]
2026-11-21 15:33 ` [PATCH 2/2] MIPS: rtlx: Call finish_wait() when rtlx_open() is interrupted Suyuan Wang via B4 Relay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261121-rtlx-v1-1-bc05d6763ec1@gmail.com \
    --to=devnull+shyckless.gmail.com@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=shyckless@gmail.com \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®