Blame SOURCES/0002-device-Fix-crash-when-connecting-ATT-with-BR-EDR-onl.patch

8866cd
From 164997007447ffbf011934e84e21040f5e3eeff4 Mon Sep 17 00:00:00 2001
8866cd
From: Gopal Tiwari <gtiwari@redhat.com>
8866cd
Date: Thu, 25 Apr 2019 19:39:41 +0530
8866cd
Subject: [PATCH BlueZ]     device: Fix crash when connecting ATT with BR/EDR
8866cd
 only device
8866cd
8866cd
commit 5252296b725ef159992be5372f60721bd9adca48
8866cd
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
8866cd
Date:   Wed Aug 9 14:14:23 2017 +0300
8866cd
8866cd
    device: Fix crash when connecting ATT with BR/EDR only device
8866cd
---
8866cd
 src/device.c | 38 +++++++++++++++++++++++---------------
8866cd
 1 file changed, 23 insertions(+), 15 deletions(-)
8866cd
8866cd
diff --git a/src/device.c b/src/device.c
8866cd
index 4d2a59522..54bef1bd3 100644
8866cd
--- a/src/device.c
8866cd
+++ b/src/device.c
8866cd
@@ -133,10 +133,15 @@ struct authentication_req {
8866cd
 	gboolean secure;
8866cd
 };
8866cd
 
8866cd
+enum {
8866cd
+	BROWSE_SDP,
8866cd
+	BROWSE_GATT
8866cd
+};
8866cd
+
8866cd
 struct browse_req {
8866cd
 	DBusMessage *msg;
8866cd
 	struct btd_device *device;
8866cd
-	uint8_t bdaddr_type;
8866cd
+	uint8_t type;
8866cd
 	GSList *match_uuids;
8866cd
 	GSList *profiles_added;
8866cd
 	sdp_list_t *records;
8866cd
@@ -2149,13 +2154,13 @@ static void store_gatt_db(struct btd_device *device)
8866cd
 }
8866cd
 
8866cd
 
8866cd
-static void browse_request_complete(struct browse_req *req, uint8_t bdaddr_type,
8866cd
-									int err)
8866cd
+static void browse_request_complete(struct browse_req *req, uint8_t type,
8866cd
+						uint8_t bdaddr_type, int err)
8866cd
 {
8866cd
 	struct btd_device *dev = req->device;
8866cd
 	DBusMessage *reply = NULL;
8866cd
 
8866cd
-	if (req->bdaddr_type != bdaddr_type)
8866cd
+	if (req->type != type)
8866cd
 		return;
8866cd
 
8866cd
 	if (!req->msg)
8866cd
@@ -2209,8 +2214,8 @@ static void device_set_svc_refreshed(struct btd_device *device, bool value)
8866cd
 					DEVICE_INTERFACE, "ServicesResolved");
8866cd
 }
8866cd
 
8866cd
-static void device_svc_resolved(struct btd_device *dev, uint8_t bdaddr_type,
8866cd
-								int err)
8866cd
+static void device_svc_resolved(struct btd_device *dev, uint8_t browse_type,
8866cd
+						uint8_t bdaddr_type, int err)
8866cd
 {
8866cd
 	struct bearer_state *state = get_state(dev, bdaddr_type);
8866cd
 	struct browse_req *req = dev->browse;
8866cd
@@ -2258,7 +2263,7 @@ static void device_svc_resolved(struct btd_device *dev, uint8_t bdaddr_type,
8866cd
 		return;
8866cd
 
8866cd
 	dev->browse = NULL;
8866cd
-	browse_request_complete(req, bdaddr_type, err);
8866cd
+	browse_request_complete(req, browse_type, bdaddr_type, err);
8866cd
 }
8866cd
 
8866cd
 static struct bonding_req *bonding_request_new(DBusMessage *msg,
8866cd
@@ -4517,7 +4522,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
8866cd
 						DEVICE_INTERFACE, "UUIDs");
8866cd
 
8866cd
 send_reply:
8866cd
-	device_svc_resolved(device, BDADDR_BREDR, err);
8866cd
+	device_svc_resolved(device, BROWSE_SDP, BDADDR_BREDR, err);
8866cd
 }
8866cd
 
8866cd
 static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
8866cd
@@ -4642,7 +4647,8 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
8866cd
 	DBG("status: %s, error: %u", success ? "success" : "failed", att_ecode);
8866cd
 
8866cd
 	if (!success) {
8866cd
-		device_svc_resolved(device, device->bdaddr_type, -EIO);
8866cd
+		device_svc_resolved(device, BROWSE_GATT, device->bdaddr_type,
8866cd
+									-EIO);
8866cd
 		return;
8866cd
 	}
8866cd
 
8866cd
@@ -4650,7 +4656,7 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
8866cd
 
8866cd
 	btd_gatt_client_ready(device->client_dbus);
8866cd
 
8866cd
-	device_svc_resolved(device, device->bdaddr_type, 0);
8866cd
+	device_svc_resolved(device, BROWSE_GATT, device->bdaddr_type, 0);
8866cd
 
8866cd
 	store_gatt_db(device);
8866cd
 }
8866cd
@@ -4855,6 +4861,7 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
8866cd
 
8866cd
 		if (device->browse) {
8866cd
 			browse_request_complete(device->browse,
8866cd
+						BROWSE_GATT,
8866cd
 						device->bdaddr_type,
8866cd
 						-ECONNABORTED);
8866cd
 			device->browse = NULL;
8866cd
@@ -4959,7 +4966,7 @@ int device_connect_le(struct btd_device *dev)
8866cd
 }
8866cd
 
8866cd
 static struct browse_req *browse_request_new(struct btd_device *device,
8866cd
-							uint8_t bdaddr_type,
8866cd
+							uint8_t type,
8866cd
 							DBusMessage *msg)
8866cd
 {
8866cd
 	struct browse_req *req;
8866cd
@@ -4969,7 +4976,7 @@ static struct browse_req *browse_request_new(struct btd_device *device,
8866cd
 
8866cd
 	req = g_new0(struct browse_req, 1);
8866cd
 	req->device = device;
8866cd
-	req->bdaddr_type = bdaddr_type;
8866cd
+	req->type = type;
8866cd
 
8866cd
 	device->browse = req;
8866cd
 
8866cd
@@ -4995,7 +5002,7 @@ static int device_browse_gatt(struct btd_device *device, DBusMessage *msg)
8866cd
 	struct btd_adapter *adapter = device->adapter;
8866cd
 	struct browse_req *req;
8866cd
 
8866cd
-	req = browse_request_new(device, device->bdaddr_type, msg);
8866cd
+	req = browse_request_new(device, BROWSE_GATT, msg);
8866cd
 	if (!req)
8866cd
 		return -EBUSY;
8866cd
 
8866cd
@@ -5011,7 +5018,8 @@ static int device_browse_gatt(struct btd_device *device, DBusMessage *msg)
8866cd
 		 * Services have already been discovered, so signal this browse
8866cd
 		 * request as resolved.
8866cd
 		 */
8866cd
-		device_svc_resolved(device, device->bdaddr_type, 0);
8866cd
+		device_svc_resolved(device, BROWSE_GATT, device->bdaddr_type,
8866cd
+									0);
8866cd
 		return 0;
8866cd
 	}
8866cd
 
8866cd
@@ -5068,7 +5076,7 @@ static int device_browse_sdp(struct btd_device *device, DBusMessage *msg)
8866cd
 	uuid_t uuid;
8866cd
 	int err;
8866cd
 
8866cd
-	req = browse_request_new(device, BDADDR_BREDR, msg);
8866cd
+	req = browse_request_new(device, BROWSE_SDP, msg);
8866cd
 	if (!req)
8866cd
 		return -EBUSY;
8866cd
 
8866cd
-- 
8866cd
2.17.2
8866cd