Skip to contentSkip to conversation

bluetooth: hci_qca: Fix suspend/resume functionality failure

PATCH Superseded Zijun Hu 2 participants 2 messages May 28, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zijun Hu

author
#0 lore raw

PATCH 1/1 bluetooth: hci_qca: Fix suspend/resume functionality failure

@dev parameter of qca_suspend()/qca_resume() represents serdev_device, but it is mistook for hci_dev and causes succedent unexpected memory access.

Fix by taking @dev as serdev_device.

---
 drivers/bluetooth/hci_qca.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/bluetooth/hci_qca.c +8 -4
index e4a6823..c159161 100644
@@ -1977,8 +1977,10 @@ static void qca_serdev_remove(struct serdev_device *serdev)
 
 static int __maybe_unused qca_suspend(struct device *dev)
 {
-	struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);
-	struct hci_uart *hu = hci_get_drvdata(hdev);
+	struct serdev_device *serdev = to_serdev_device(dev);
+	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
+	struct hci_uart *hu = &qcadev->serdev_hu;
+	struct hci_dev *hdev __maybe_unused = hu->hdev;
 	struct qca_data *qca = hu->priv;
 	unsigned long flags;
 	int ret = 0;
@@ -2057,8 +2059,10 @@ static int __maybe_unused qca_suspend(struct device *dev)
 
 static int __maybe_unused qca_resume(struct device *dev)
 {
-	struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);
-	struct hci_uart *hu = hci_get_drvdata(hdev);
+	struct serdev_device *serdev = to_serdev_device(dev);
+	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
+	struct hci_uart *hu = &qcadev->serdev_hu;
+	struct hci_dev *hdev __maybe_unused = hu->hdev;
 	struct qca_data *qca = hu->priv;
 
 	clear_bit(QCA_SUSPENDING, &qca->flags);
Signature · 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
#1 lore raw

Hi Zijun,

Quoted 7 lines · Zijun Hu

@dev parameter of qca_suspend()/qca_resume() represents serdev_device, but it is mistook for hci_dev and causes succedent unexpected memory access.

Fix by taking @dev as serdev_device.

Please add:

Fixes 41d5b25fed0 ("Bluetooth: hci_qca: add PM support")

and add [email protected] to cc:

Quoted 9 lines
---
 drivers/bluetooth/hci_qca.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/bluetooth/hci_qca.c +0 -0
index e4a6823..c159161 100644

drivers/bluetooth/hci_qca.c static void qca_serdev_remove(struct serdev_device *serdev) · line 1983

Quoted 9 lines
drivers/bluetooth/hci_qca.c +4 -2
@@ -1977,8 +1977,10 @@ static void qca_serdev_remove(struct serdev_device *serdev)
 
 static int __maybe_unused qca_suspend(struct device *dev)
 {
-	struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);
-	struct hci_uart *hu = hci_get_drvdata(hdev);
+	struct serdev_device *serdev = to_serdev_device(dev);
+	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
+	struct hci_uart *hu = &qcadev->serdev_hu;
+	struct hci_dev *hdev __maybe_unused = hu->hdev;

hdev is not used, please remove

drivers/bluetooth/hci_qca.c static int __maybe_unused qca_suspend(struct device *dev) · line 2065

Quoted 13 lines
drivers/bluetooth/hci_qca.c +4 -2
 	struct qca_data *qca = hu->priv;
 	unsigned long flags;
 	int ret = 0;
@@ -2057,8 +2059,10 @@ static int __maybe_unused qca_suspend(struct device *dev)
 
 static int __maybe_unused qca_resume(struct device *dev)
 {
-	struct hci_dev *hdev = container_of(dev, struct hci_dev, dev);
-	struct hci_uart *hu = hci_get_drvdata(hdev);
+	struct serdev_device *serdev = to_serdev_device(dev);
+	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
+	struct hci_uart *hu = &qcadev->serdev_hu;
+	struct hci_dev *hdev __maybe_unused = hu->hdev;

hdev is not used, please remove

Quoted 6 lines
drivers/bluetooth/hci_qca.c +0 -0
 	struct qca_data *qca = hu->priv;
 
 	clear_bit(QCA_SUSPENDING, &qca->flags);
Signature · 1 line
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project