[PATCH] Bluetooth: hci_uart: add missing NULL check in h5_enqueue

Pavel Skripkin posted 1 patch 4 years, 3 months ago
drivers/bluetooth/hci_h5.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
[PATCH] Bluetooth: hci_uart: add missing NULL check in h5_enqueue
Posted by Pavel Skripkin 4 years, 3 months ago
Syzbot hit general protection fault in __pm_runtime_resume(). The problem
was in missing NULL check.

hu->serdev can be NULL and we should not blindly pass &serdev->dev
somewhere, since it will cause GPF.

Reported-by: syzbot+b9bd12fbed3485a3e51f@syzkaller.appspotmail.com
Fixes: d9dd833cf6d2 ("Bluetooth: hci_h5: Add runtime suspend")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 drivers/bluetooth/hci_h5.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 34286ffe0568..7ac6908a4dfb 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -629,9 +629,11 @@ static int h5_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 		break;
 	}
 
-	pm_runtime_get_sync(&hu->serdev->dev);
-	pm_runtime_mark_last_busy(&hu->serdev->dev);
-	pm_runtime_put_autosuspend(&hu->serdev->dev);
+	if (hu->serdev) {
+		pm_runtime_get_sync(&hu->serdev->dev);
+		pm_runtime_mark_last_busy(&hu->serdev->dev);
+		pm_runtime_put_autosuspend(&hu->serdev->dev);
+	}
 
 	return 0;
 }
-- 
2.35.1
Re: [PATCH] Bluetooth: hci_uart: add missing NULL check in h5_enqueue
Posted by Marcel Holtmann 4 years, 3 months ago
Hi Pavel,

> Syzbot hit general protection fault in __pm_runtime_resume(). The problem
> was in missing NULL check.
> 
> hu->serdev can be NULL and we should not blindly pass &serdev->dev
> somewhere, since it will cause GPF.
> 
> Reported-by: syzbot+b9bd12fbed3485a3e51f@syzkaller.appspotmail.com
> Fixes: d9dd833cf6d2 ("Bluetooth: hci_h5: Add runtime suspend")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
> ---
> drivers/bluetooth/hci_h5.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

However if someone would finally step up and write a standalone serdev only driver for 3-Wire UART support, this would not be a problem in the first place. We are just applying on bandaid after another.

Regards

Marcel
Re: [PATCH] Bluetooth: hci_uart: add missing NULL check in h5_enqueue
Posted by patchwork-bot+bluetooth@kernel.org 4 years, 3 months ago
Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Marcel Holtmann <marcel@holtmann.org>:

On Sun, 13 Mar 2022 20:49:36 +0300 you wrote:
> Syzbot hit general protection fault in __pm_runtime_resume(). The problem
> was in missing NULL check.
> 
> hu->serdev can be NULL and we should not blindly pass &serdev->dev
> somewhere, since it will cause GPF.
> 
> Reported-by: syzbot+b9bd12fbed3485a3e51f@syzkaller.appspotmail.com
> Fixes: d9dd833cf6d2 ("Bluetooth: hci_h5: Add runtime suspend")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
> 
> [...]

Here is the summary with links:
  - Bluetooth: hci_uart: add missing NULL check in h5_enqueue
    https://git.kernel.org/bluetooth/bluetooth-next/c/928df045e94e

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