All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] shared/gatt-client: Fix possible crash
@ 2015-04-01 12:18 Luiz Augusto von Dentz
  2015-04-02  8:21 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2015-04-01 12:18 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Similar to issue found with unit test it is necessary to protect
bt_gatt_client instance before calling the callback otherwise it may
destroy it causing a crash.
---
 src/shared/gatt-client.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index df994d7..b92d7b1 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -2456,14 +2456,17 @@ static void complete_write_long_op(struct request *req, bool success,
 	if (req->att_id)
 		return;
 
-
 	request_unref(req);
 	success = false;
 
+	bt_gatt_client_ref(op->client);
+
 	if (op->callback)
 		op->callback(success, reliable_error, att_ecode, op->user_data);
 
 	start_next_long_write(op->client);
+
+	bt_gatt_client_unref(op->client);
 }
 
 static void prepare_write_cb(uint8_t opcode, const void *pdu, uint16_t length,
-- 
2.1.0


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

* Re: [PATCH BlueZ] shared/gatt-client: Fix possible crash
  2015-04-01 12:18 [PATCH BlueZ] shared/gatt-client: Fix possible crash Luiz Augusto von Dentz
@ 2015-04-02  8:21 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2015-04-02  8:21 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Wed, Apr 1, 2015 at 3:18 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> Similar to issue found with unit test it is necessary to protect
> bt_gatt_client instance before calling the callback otherwise it may
> destroy it causing a crash.
> ---
>  src/shared/gatt-client.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
> index df994d7..b92d7b1 100644
> --- a/src/shared/gatt-client.c
> +++ b/src/shared/gatt-client.c
> @@ -2456,14 +2456,17 @@ static void complete_write_long_op(struct request *req, bool success,
>         if (req->att_id)
>                 return;
>
> -
>         request_unref(req);
>         success = false;
>
> +       bt_gatt_client_ref(op->client);
> +
>         if (op->callback)
>                 op->callback(success, reliable_error, att_ecode, op->user_data);
>
>         start_next_long_write(op->client);
> +
> +       bt_gatt_client_unref(op->client);
>  }
>
>  static void prepare_write_cb(uint8_t opcode, const void *pdu, uint16_t length,
> --
> 2.1.0

Applied.


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2015-04-02  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01 12:18 [PATCH BlueZ] shared/gatt-client: Fix possible crash Luiz Augusto von Dentz
2015-04-02  8:21 ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.