[SRU OEM-B][PATCH 2/3] UBUNTU: SAUCE: Bluetooth:btrsi: add null check in hci send and recv functions
Shrirang Bagul
shrirang.bagul at canonical.com
Tue May 22 10:49:11 UTC 2018
From: Ganapathi Raju <ganapathi.kondraju at redpinesignals.com>
BugLink: http://bugs.launchpad.net/bugs/1772626
During power save S3 and S4 stress tests driver sometimes crashes
because of accessing the hdev pointer in rsi_hci_recv_pkt() and
rsi_hci_send_pkt() which is NULL. Fixed by adding NULL check
before accessing hdev in these functions.
Signed-off-by: Ganapathi Raju <ganapathi.kondraju at redpinesignals.com>
Signed-off-by: Shrirang Bagul <shrirang.bagul at canonical.com>
---
drivers/bluetooth/btrsi.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/bluetooth/btrsi.c b/drivers/bluetooth/btrsi.c
index 5034325e417c..5dfb2f462f42 100644
--- a/drivers/bluetooth/btrsi.c
+++ b/drivers/bluetooth/btrsi.c
@@ -51,6 +51,9 @@ static int rsi_hci_send_pkt(struct hci_dev *hdev, struct sk_buff *skb)
struct rsi_hci_adapter *h_adapter = hci_get_drvdata(hdev);
struct sk_buff *new_skb = NULL;
+ if (!h_adapter->hdev)
+ return -ENODEV;
+
switch (hci_skb_pkt_type(skb)) {
case HCI_COMMAND_PKT:
hdev->stat.cmd_tx++;
@@ -84,6 +87,9 @@ static int rsi_hci_recv_pkt(void *priv, const u8 *pkt)
struct sk_buff *skb;
int pkt_len = get_unaligned_le16(pkt) & 0x0fff;
+ if (!h_adapter->hdev)
+ return -ENODEV;
+
skb = dev_alloc_skb(pkt_len);
if (!skb)
return -ENOMEM;
--
2.17.0
More information about the kernel-team
mailing list