Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: hci_mrvl: Fix wrong return value check of wait_on_bit_timeout()
@ 2026-08-25  2:01 Gongwei Li
  2026-08-31 17:20 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 2+ messages in thread
From: Gongwei Li @ 2026-08-25  2:01 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Loic Poulain, linux-bluetooth, linux-kernel, Gongwei Li

From: Gongwei Li <ligongwei@kylinos.cn>

wait_on_bit_timeout() returns 0 if the bit was cleared, -EINTR if the
process received a signal and the mode permitted wake up on that signal,
or -EAGAIN if the timeout elapsed.  It never returns 1.

Hence the check "err == 1" in mrvl_load_firmware() is dead code: when
the waiting task is interrupted by a signal (-EINTR), the code falls
into the "else if (err)" branch and misreports it as "Firmware request
timeout" with -ETIMEDOUT instead of propagating -EINTR.

Fix this by testing for -EINTR so that an interrupted firmware load is
properly detected and reported.

Fixes: 162f812f23ba ("Bluetooth: hci_uart: Add Marvell support")
Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>

---
Changes in v2:
- Drop the redundant "err = -EINTR;" assignment inside the err == -EINTR
  branch since err already holds -EINTR there.
---
 drivers/bluetooth/hci_mrvl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_mrvl.c b/drivers/bluetooth/hci_mrvl.c
index 516b8f74c434..5798a8db016e 100644
--- a/drivers/bluetooth/hci_mrvl.c
+++ b/drivers/bluetooth/hci_mrvl.c
@@ -307,9 +307,8 @@ static int mrvl_load_firmware(struct hci_dev *hdev, const char *name)
 		err = wait_on_bit_timeout(&mrvl->flags, STATE_FW_REQ_PENDING,
 					  TASK_INTERRUPTIBLE,
 					  msecs_to_jiffies(2000));
-		if (err == 1) {
+		if (err == -EINTR) {
 			bt_dev_err(hdev, "Firmware load interrupted");
-			err = -EINTR;
 			break;
 		} else if (err) {
 			bt_dev_err(hdev, "Firmware request timeout");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Bluetooth: hci_mrvl: Fix wrong return value check of wait_on_bit_timeout()
  2026-08-25  2:01 [PATCH v2] Bluetooth: hci_mrvl: Fix wrong return value check of wait_on_bit_timeout() Gongwei Li
@ 2026-08-31 17:20 ` patchwork-bot+bluetooth
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2026-08-31 17:20 UTC (permalink / raw)
  To: Gongwei Li
  Cc: marcel, luiz.dentz, loic.poulain, linux-bluetooth, linux-kernel,
	ligongwei

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 25 Aug 2026 10:01:45 +0800 you wrote:
> From: Gongwei Li <ligongwei@kylinos.cn>
> 
> wait_on_bit_timeout() returns 0 if the bit was cleared, -EINTR if the
> process received a signal and the mode permitted wake up on that signal,
> or -EAGAIN if the timeout elapsed.  It never returns 1.
> 
> Hence the check "err == 1" in mrvl_load_firmware() is dead code: when
> the waiting task is interrupted by a signal (-EINTR), the code falls
> into the "else if (err)" branch and misreports it as "Firmware request
> timeout" with -ETIMEDOUT instead of propagating -EINTR.
> 
> [...]

Here is the summary with links:
  - [v2] Bluetooth: hci_mrvl: Fix wrong return value check of wait_on_bit_timeout()
    https://git.kernel.org/bluetooth/bluetooth-next/c/870187be2362

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-31 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25  2:01 [PATCH v2] Bluetooth: hci_mrvl: Fix wrong return value check of wait_on_bit_timeout() Gongwei Li
2026-08-31 17:20 ` patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox