linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci: fix GPF in h5_recv
@ 2021-09-02 20:27 Pavel Skripkin
  2021-09-10  7:39 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Skripkin @ 2021-09-02 20:27 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz
  Cc: apusaka, abhishekpandit, linux-bluetooth, linux-kernel,
	Pavel Skripkin, syzbot+7d41312fe3f123a6f605

Syzbot hit general protection fault in h5_recv(). The problem was in
missing NULL check.

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

Fixes: d9dd833cf6d2 ("Bluetooth: hci_h5: Add runtime suspend")
Reported-and-tested-by: syzbot+7d41312fe3f123a6f605@syzkaller.appspotmail.com
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 0c0dedece59c..eb0099a21288 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -587,9 +587,11 @@ static int h5_recv(struct hci_uart *hu, const void *data, int count)
 		count -= processed;
 	}
 
-	pm_runtime_get(&hu->serdev->dev);
-	pm_runtime_mark_last_busy(&hu->serdev->dev);
-	pm_runtime_put_autosuspend(&hu->serdev->dev);
+	if (hu->serdev) {
+		pm_runtime_get(&hu->serdev->dev);
+		pm_runtime_mark_last_busy(&hu->serdev->dev);
+		pm_runtime_put_autosuspend(&hu->serdev->dev);
+	}
 
 	return 0;
 }
-- 
2.33.0


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

* Re: [PATCH] Bluetooth: hci: fix GPF in h5_recv
  2021-09-02 20:27 [PATCH] Bluetooth: hci: fix GPF in h5_recv Pavel Skripkin
@ 2021-09-10  7:39 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2021-09-10  7:39 UTC (permalink / raw)
  To: Pavel Skripkin
  Cc: Johan Hedberg, Luiz Augusto von Dentz, apusaka, abhishekpandit,
	linux-bluetooth, linux-kernel, syzbot+7d41312fe3f123a6f605

Hi Pavel,

> Syzbot hit general protection fault in h5_recv(). The problem was in
> missing NULL check.
> 
> hu->serdev can be NULL and we cannot blindly pass &serdev->dev
> somewhere, since it can cause GPF.
> 
> Fixes: d9dd833cf6d2 ("Bluetooth: hci_h5: Add runtime suspend")
> Reported-and-tested-by: syzbot+7d41312fe3f123a6f605@syzkaller.appspotmail.com
> 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.

Regards

Marcel


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

end of thread, other threads:[~2021-09-10  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 20:27 [PATCH] Bluetooth: hci: fix GPF in h5_recv Pavel Skripkin
2021-09-10  7:39 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).