* [PATCH] src/device: Free bonding while failed to pair device
@ 2016-09-30 15:39 jiangbo.wu
2016-10-01 16:55 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 5+ messages in thread
From: jiangbo.wu @ 2016-09-30 15:39 UTC (permalink / raw)
To: martin.xu, johan.hedberg; +Cc: linux-bluetooth, Jiangbo Wu
From: Jiangbo Wu <jiangbo.wu@intel.com>
---
src/device.c | 62 +++++++++++++++++++++++++++++++-----------------------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/src/device.c b/src/device.c
index 25d2e22..fb6104f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2314,6 +2314,35 @@ static void create_bond_req_exit(DBusConnection *conn, void *user_data)
}
}
+static void bonding_request_free(struct bonding_req *bonding)
+{
+ if (!bonding)
+ return;
+
+ if (bonding->listener_id)
+ g_dbus_remove_watch(dbus_conn, bonding->listener_id);
+
+ if (bonding->msg)
+ dbus_message_unref(bonding->msg);
+
+ if (bonding->cb_iter)
+ g_free(bonding->cb_iter);
+
+ if (bonding->agent) {
+ agent_cancel(bonding->agent);
+ agent_unref(bonding->agent);
+ bonding->agent = NULL;
+ }
+
+ if (bonding->retry_timer)
+ g_source_remove(bonding->retry_timer);
+
+ if (bonding->device)
+ bonding->device->bonding = NULL;
+
+ g_free(bonding);
+}
+
static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -2384,8 +2413,10 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
BDADDR_BREDR, io_cap);
}
- if (err < 0)
+ if (err < 0) {
+ bonding_request_free(device->bonding);
return btd_error_failed(msg, strerror(-err));
+ }
return NULL;
}
@@ -2426,35 +2457,6 @@ static DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
}
}
-static void bonding_request_free(struct bonding_req *bonding)
-{
- if (!bonding)
- return;
-
- if (bonding->listener_id)
- g_dbus_remove_watch(dbus_conn, bonding->listener_id);
-
- if (bonding->msg)
- dbus_message_unref(bonding->msg);
-
- if (bonding->cb_iter)
- g_free(bonding->cb_iter);
-
- if (bonding->agent) {
- agent_cancel(bonding->agent);
- agent_unref(bonding->agent);
- bonding->agent = NULL;
- }
-
- if (bonding->retry_timer)
- g_source_remove(bonding->retry_timer);
-
- if (bonding->device)
- bonding->device->bonding = NULL;
-
- g_free(bonding);
-}
-
static void device_cancel_bonding(struct btd_device *device, uint8_t status)
{
struct bonding_req *bonding = device->bonding;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] src/device: Free bonding while failed to pair device
2016-09-30 15:39 jiangbo.wu
@ 2016-10-01 16:55 ` Luiz Augusto von Dentz
2016-10-02 12:30 ` Wu, Jiangbo
0 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-10-01 16:55 UTC (permalink / raw)
To: Wu, Jiangbo; +Cc: Xu, Martin, Johan Hedberg, linux-bluetooth@vger.kernel.org
Hi,
On Fri, Sep 30, 2016 at 6:39 PM, <jiangbo.wu@intel.com> wrote:
> From: Jiangbo Wu <jiangbo.wu@intel.com>
It would be good to have something in the patch description, perhaps
the backtrace if this is a crash fix or perhaps this comes from a
static analyzer?
> ---
> src/device.c | 62 +++++++++++++++++++++++++++++++-----------------------------
> 1 file changed, 32 insertions(+), 30 deletions(-)
>
> diff --git a/src/device.c b/src/device.c
> index 25d2e22..fb6104f 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -2314,6 +2314,35 @@ static void create_bond_req_exit(DBusConnection *conn, void *user_data)
> }
> }
>
> +static void bonding_request_free(struct bonding_req *bonding)
> +{
> + if (!bonding)
> + return;
> +
> + if (bonding->listener_id)
> + g_dbus_remove_watch(dbus_conn, bonding->listener_id);
> +
> + if (bonding->msg)
> + dbus_message_unref(bonding->msg);
> +
> + if (bonding->cb_iter)
> + g_free(bonding->cb_iter);
> +
> + if (bonding->agent) {
> + agent_cancel(bonding->agent);
> + agent_unref(bonding->agent);
> + bonding->agent = NULL;
> + }
> +
> + if (bonding->retry_timer)
> + g_source_remove(bonding->retry_timer);
> +
> + if (bonding->device)
> + bonding->device->bonding = NULL;
> +
> + g_free(bonding);
> +}
> +
> static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> void *data)
> {
> @@ -2384,8 +2413,10 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> BDADDR_BREDR, io_cap);
> }
>
> - if (err < 0)
> + if (err < 0) {
> + bonding_request_free(device->bonding);
> return btd_error_failed(msg, strerror(-err));
> + }
>
> return NULL;
> }
> @@ -2426,35 +2457,6 @@ static DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
> }
> }
>
> -static void bonding_request_free(struct bonding_req *bonding)
> -{
> - if (!bonding)
> - return;
> -
> - if (bonding->listener_id)
> - g_dbus_remove_watch(dbus_conn, bonding->listener_id);
> -
> - if (bonding->msg)
> - dbus_message_unref(bonding->msg);
> -
> - if (bonding->cb_iter)
> - g_free(bonding->cb_iter);
> -
> - if (bonding->agent) {
> - agent_cancel(bonding->agent);
> - agent_unref(bonding->agent);
> - bonding->agent = NULL;
> - }
> -
> - if (bonding->retry_timer)
> - g_source_remove(bonding->retry_timer);
> -
> - if (bonding->device)
> - bonding->device->bonding = NULL;
> -
> - g_free(bonding);
> -}
> -
> static void device_cancel_bonding(struct btd_device *device, uint8_t status)
> {
> struct bonding_req *bonding = device->bonding;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] src/device: Free bonding while failed to pair device
2016-10-01 16:55 ` Luiz Augusto von Dentz
@ 2016-10-02 12:30 ` Wu, Jiangbo
0 siblings, 0 replies; 5+ messages in thread
From: Wu, Jiangbo @ 2016-10-02 12:30 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Xu, Martin, Johan Hedberg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aW5nID0gTlVMTDsNCj4g
LQ0KPiAtICAgICAgIGdfZnJlZShib25kaW5nKTsNCj4gLX0NCj4gLQ0KPiAgc3RhdGljIHZvaWQg
ZGV2aWNlX2NhbmNlbF9ib25kaW5nKHN0cnVjdCBidGRfZGV2aWNlICpkZXZpY2UsIHVpbnQ4X3Qg
DQo+IHN0YXR1cykgIHsNCj4gICAgICAgICBzdHJ1Y3QgYm9uZGluZ19yZXEgKmJvbmRpbmcgPSBk
ZXZpY2UtPmJvbmRpbmc7DQo+IC0tDQo+IDEuOS4xDQo+DQo+IC0tDQo+IFRvIHVuc3Vic2NyaWJl
IGZyb20gdGhpcyBsaXN0OiBzZW5kIHRoZSBsaW5lICJ1bnN1YnNjcmliZSANCj4gbGludXgtYmx1
ZXRvb3RoIiBpbiB0aGUgYm9keSBvZiBhIG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIua2VybmVs
Lm9yZyANCj4gTW9yZSBtYWpvcmRvbW8gaW5mbyBhdCAgaHR0cDovL3ZnZXIua2VybmVsLm9yZy9t
YWpvcmRvbW8taW5mby5odG1sDQoNCg0KDQotLQ0KTHVpeiBBdWd1c3RvIHZvbiBEZW50eg0K
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] src/device: Free bonding while failed to pair device
@ 2016-10-02 12:38 jiangbo.wu
2016-10-03 8:11 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 5+ messages in thread
From: jiangbo.wu @ 2016-10-02 12:38 UTC (permalink / raw)
To: luiz.dentz, martin.xu, johan.hedberg; +Cc: linux-bluetooth, Jiangbo Wu
From: Jiangbo Wu <jiangbo.wu@intel.com>
device unable pair since another pairng is in progress, and need to
free bonding before it created for next pairing.
---
src/device.c | 62 +++++++++++++++++++++++++++++++-----------------------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/src/device.c b/src/device.c
index 25d2e22..fb6104f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2314,6 +2314,35 @@ static void create_bond_req_exit(DBusConnection *conn, void *user_data)
}
}
+static void bonding_request_free(struct bonding_req *bonding)
+{
+ if (!bonding)
+ return;
+
+ if (bonding->listener_id)
+ g_dbus_remove_watch(dbus_conn, bonding->listener_id);
+
+ if (bonding->msg)
+ dbus_message_unref(bonding->msg);
+
+ if (bonding->cb_iter)
+ g_free(bonding->cb_iter);
+
+ if (bonding->agent) {
+ agent_cancel(bonding->agent);
+ agent_unref(bonding->agent);
+ bonding->agent = NULL;
+ }
+
+ if (bonding->retry_timer)
+ g_source_remove(bonding->retry_timer);
+
+ if (bonding->device)
+ bonding->device->bonding = NULL;
+
+ g_free(bonding);
+}
+
static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -2384,8 +2413,10 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
BDADDR_BREDR, io_cap);
}
- if (err < 0)
+ if (err < 0) {
+ bonding_request_free(device->bonding);
return btd_error_failed(msg, strerror(-err));
+ }
return NULL;
}
@@ -2426,35 +2457,6 @@ static DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
}
}
-static void bonding_request_free(struct bonding_req *bonding)
-{
- if (!bonding)
- return;
-
- if (bonding->listener_id)
- g_dbus_remove_watch(dbus_conn, bonding->listener_id);
-
- if (bonding->msg)
- dbus_message_unref(bonding->msg);
-
- if (bonding->cb_iter)
- g_free(bonding->cb_iter);
-
- if (bonding->agent) {
- agent_cancel(bonding->agent);
- agent_unref(bonding->agent);
- bonding->agent = NULL;
- }
-
- if (bonding->retry_timer)
- g_source_remove(bonding->retry_timer);
-
- if (bonding->device)
- bonding->device->bonding = NULL;
-
- g_free(bonding);
-}
-
static void device_cancel_bonding(struct btd_device *device, uint8_t status)
{
struct bonding_req *bonding = device->bonding;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] src/device: Free bonding while failed to pair device
2016-10-02 12:38 [PATCH] src/device: Free bonding while failed to pair device jiangbo.wu
@ 2016-10-03 8:11 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-10-03 8:11 UTC (permalink / raw)
To: Wu, Jiangbo; +Cc: Xu, Martin, Johan Hedberg, linux-bluetooth@vger.kernel.org
Hi,
On Sun, Oct 2, 2016 at 3:38 PM, <jiangbo.wu@intel.com> wrote:
> From: Jiangbo Wu <jiangbo.wu@intel.com>
>
> device unable pair since another pairng is in progress, and need to
> free bonding before it created for next pairing.
> ---
> src/device.c | 62 +++++++++++++++++++++++++++++++-----------------------------
> 1 file changed, 32 insertions(+), 30 deletions(-)
>
> diff --git a/src/device.c b/src/device.c
> index 25d2e22..fb6104f 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -2314,6 +2314,35 @@ static void create_bond_req_exit(DBusConnection *conn, void *user_data)
> }
> }
>
> +static void bonding_request_free(struct bonding_req *bonding)
> +{
> + if (!bonding)
> + return;
> +
> + if (bonding->listener_id)
> + g_dbus_remove_watch(dbus_conn, bonding->listener_id);
> +
> + if (bonding->msg)
> + dbus_message_unref(bonding->msg);
> +
> + if (bonding->cb_iter)
> + g_free(bonding->cb_iter);
> +
> + if (bonding->agent) {
> + agent_cancel(bonding->agent);
> + agent_unref(bonding->agent);
> + bonding->agent = NULL;
> + }
> +
> + if (bonding->retry_timer)
> + g_source_remove(bonding->retry_timer);
> +
> + if (bonding->device)
> + bonding->device->bonding = NULL;
> +
> + g_free(bonding);
> +}
> +
> static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> void *data)
> {
> @@ -2384,8 +2413,10 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> BDADDR_BREDR, io_cap);
> }
>
> - if (err < 0)
> + if (err < 0) {
> + bonding_request_free(device->bonding);
> return btd_error_failed(msg, strerror(-err));
> + }
>
> return NULL;
> }
> @@ -2426,35 +2457,6 @@ static DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
> }
> }
>
> -static void bonding_request_free(struct bonding_req *bonding)
> -{
> - if (!bonding)
> - return;
> -
> - if (bonding->listener_id)
> - g_dbus_remove_watch(dbus_conn, bonding->listener_id);
> -
> - if (bonding->msg)
> - dbus_message_unref(bonding->msg);
> -
> - if (bonding->cb_iter)
> - g_free(bonding->cb_iter);
> -
> - if (bonding->agent) {
> - agent_cancel(bonding->agent);
> - agent_unref(bonding->agent);
> - bonding->agent = NULL;
> - }
> -
> - if (bonding->retry_timer)
> - g_source_remove(bonding->retry_timer);
> -
> - if (bonding->device)
> - bonding->device->bonding = NULL;
> -
> - g_free(bonding);
> -}
> -
> static void device_cancel_bonding(struct btd_device *device, uint8_t status)
> {
> struct bonding_req *bonding = device->bonding;
> --
> 1.9.1
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-03 8:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-02 12:38 [PATCH] src/device: Free bonding while failed to pair device jiangbo.wu
2016-10-03 8:11 ` Luiz Augusto von Dentz
-- strict thread matches above, loose matches on Subject: below --
2016-09-30 15:39 jiangbo.wu
2016-10-01 16:55 ` Luiz Augusto von Dentz
2016-10-02 12:30 ` Wu, Jiangbo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox