2014-12-19 14:01:28

by Gowtham Anandha Babu

[permalink] [raw]
Subject: [PATCH] src/att: Fix usage of memory after it is freed.

warning: Use of memory after it is freed
respond_not_supported(att, opcode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
src/shared/att.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/att.c b/src/shared/att.c
index 4be0652..a98909e 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -692,14 +692,14 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,

queue_foreach(att->notify_list, notify_handler, &data);

- bt_att_unref(att);
-
/*
* If this was a request and no handler was registered for it, respond
* with "Not Supported"
*/
if (!data.handler_found && get_op_type(opcode) == ATT_OP_TYPE_REQ)
respond_not_supported(att, opcode);
+
+ bt_att_unref(att);
}

static bool can_read_data(struct io *io, void *user_data)
--
1.9.1



2015-01-07 13:34:13

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] src/att: Fix usage of memory after it is freed.

Hi,

On Wed, Jan 7, 2015 at 7:56 AM, Gowtham Anandha Babu
<[email protected]> wrote:
> Ping.
>
>> -----Original Message-----
>> From: [email protected] [mailto:linux-bluetooth-
>> [email protected]] On Behalf Of Gowtham Anandha Babu
>> Sent: Friday, December 19, 2014 7:31 PM
>> To: [email protected]
>> Cc: [email protected]; [email protected];
>> [email protected]; Gowtham Anandha Babu
>> Subject: [PATCH] src/att: Fix usage of memory after it is freed.
>>
>> warning: Use of memory after it is freed
>> respond_not_supported(att, opcode);
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ---
>> src/shared/att.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/shared/att.c b/src/shared/att.c index 4be0652..a98909e
>> 100644
>> --- a/src/shared/att.c
>> +++ b/src/shared/att.c
>> @@ -692,14 +692,14 @@ static void handle_notify(struct bt_att *att,
> uint8_t
>> opcode, uint8_t *pdu,
>>
>> queue_foreach(att->notify_list, notify_handler, &data);
>>
>> - bt_att_unref(att);
>> -
>> /*
>> * If this was a request and no handler was registered for it,
> respond
>> * with "Not Supported"
>> */
>> if (!data.handler_found && get_op_type(opcode) ==
>> ATT_OP_TYPE_REQ)
>> respond_not_supported(att, opcode);
>> +
>> + bt_att_unref(att);
>> }
>>
>> static bool can_read_data(struct io *io, void *user_data)
>> --
>> 1.9.1

Applied, thanks.


--
Luiz Augusto von Dentz

2015-01-07 09:56:02

by Gowtham Anandha Babu

[permalink] [raw]
Subject: RE: [PATCH] src/att: Fix usage of memory after it is freed.

Ping.

> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Gowtham Anandha Babu
> Sent: Friday, December 19, 2014 7:31 PM
> To: [email protected]
> Cc: [email protected]; [email protected];
> [email protected]; Gowtham Anandha Babu
> Subject: [PATCH] src/att: Fix usage of memory after it is freed.
>
> warning: Use of memory after it is freed
> respond_not_supported(att, opcode);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ---
> src/shared/att.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/shared/att.c b/src/shared/att.c index 4be0652..a98909e
> 100644
> --- a/src/shared/att.c
> +++ b/src/shared/att.c
> @@ -692,14 +692,14 @@ static void handle_notify(struct bt_att *att,
uint8_t
> opcode, uint8_t *pdu,
>
> queue_foreach(att->notify_list, notify_handler, &data);
>
> - bt_att_unref(att);
> -
> /*
> * If this was a request and no handler was registered for it,
respond
> * with "Not Supported"
> */
> if (!data.handler_found && get_op_type(opcode) ==
> ATT_OP_TYPE_REQ)
> respond_not_supported(att, opcode);
> +
> + bt_att_unref(att);
> }
>
> static bool can_read_data(struct io *io, void *user_data)
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
in
> the body of a message to [email protected] More majordomo
> info at http://vger.kernel.org/majordomo-info.html