In gatt-client and gatt-helpers, the variables are accessed
even after it is freed. Making the unref at appropriate
places solved the issues.
In tools, removed dead code warnings.
Gowtham Anandha Babu (3):
shared/gatt-helpers: Fix usage of freed memory
shared/gatt-client: Fix usage of freed memory
tools/hciattach_ath3k: Remove dead code warnings
src/shared/gatt-client.c | 23 +++++++++++------------
src/shared/gatt-helpers.c | 25 ++++++++++++++++---------
tools/hciattach_ath3k.c | 11 +----------
3 files changed, 28 insertions(+), 31 deletions(-)
--
1.9.1
Hi Luiz,
> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Luiz Augusto von Dentz
> Sent: Thursday, January 22, 2015 2:33 PM
> To: Gowtham Anandha Babu
> Cc: [email protected]; Bharat Panda; [email protected]
> Subject: Re: [PATCH 0/3] Fix memory issue and trivial code cleaup
>
> Hi Gowtham,
>
> On Tue, Jan 20, 2015 at 11:34 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: Wednesday, January 14, 2015 3:28 PM
> >> To: [email protected]
> >> Cc: [email protected]; [email protected]; Gowtham
> Anandha Babu
> >> Subject: [PATCH 0/3] Fix memory issue and trivial code cleaup
> >>
> >> In gatt-client and gatt-helpers, the variables are accessed even
> >> after it
> > is
> >> freed. Making the unref at appropriate places solved the issues.
> >>
> >> In tools, removed dead code warnings.
> >>
> >> Gowtham Anandha Babu (3):
> >> shared/gatt-helpers: Fix usage of freed memory
> >> shared/gatt-client: Fix usage of freed memory
> >> tools/hciattach_ath3k: Remove dead code warnings
> >>
> >> src/shared/gatt-client.c | 23 +++++++++++------------
> >> src/shared/gatt- helpers.c | 25 ++++++++++++++++---------
> >> tools/hciattach_ath3k.c | 11 +----------
> >> 3 files changed, 28 insertions(+), 31 deletions(-)
> >>
> >> --
> >> 1.9.1
>
> Doesn't apply anymore, please rebase.
>
>
I have rebased the patches and sent the v1 for the same.
Regards,
Gowtham Anandha Babu
>
> --
> Luiz Augusto von Dentz
> --
> 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
Hi Gowtham,
On Tue, Jan 20, 2015 at 11:34 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: Wednesday, January 14, 2015 3:28 PM
>> To: [email protected]
>> Cc: [email protected]; [email protected]; Gowtham Anandha
>> Babu
>> Subject: [PATCH 0/3] Fix memory issue and trivial code cleaup
>>
>> In gatt-client and gatt-helpers, the variables are accessed even after it
> is
>> freed. Making the unref at appropriate places solved the issues.
>>
>> In tools, removed dead code warnings.
>>
>> Gowtham Anandha Babu (3):
>> shared/gatt-helpers: Fix usage of freed memory
>> shared/gatt-client: Fix usage of freed memory
>> tools/hciattach_ath3k: Remove dead code warnings
>>
>> src/shared/gatt-client.c | 23 +++++++++++------------ src/shared/gatt-
>> helpers.c | 25 ++++++++++++++++---------
>> tools/hciattach_ath3k.c | 11 +----------
>> 3 files changed, 28 insertions(+), 31 deletions(-)
>>
>> --
>> 1.9.1
Doesn't apply anymore, please rebase.
--
Luiz Augusto von Dentz
Ping.
> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: [email protected]
> Cc: [email protected]; [email protected]; Gowtham Anandha
> Babu
> Subject: [PATCH 3/3] tools/hciattach_ath3k: Remove dead code warnings
>
> tools/hciattach_ath3k.c:848:3: warning: Value stored to 'err' is never
read
> err = 0;
> ^ ~
> tools/hciattach_ath3k.c:852:3: warning: Value stored to 'err' is never
read
> err = 0;
> ^ ~
> ---
> tools/hciattach_ath3k.c | 11 +----------
> 1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c index
> 23208c6..d31732e 100644
> --- a/tools/hciattach_ath3k.c
> +++ b/tools/hciattach_ath3k.c
> @@ -840,17 +840,8 @@ static int ath_ps_download(int fd)
> goto download_cmplete;
> }
>
> - /*
> - * It is not necessary that Patch file be available,
> - * continue with PS Operations if patch file is not available.
> - */
> - if (patch_file[0] == '\0')
> - err = 0;
> -
> stream = fopen(patch_file, "r");
> - if (!stream)
> - err = 0;
> - else {
> + if(stream) {
> patch_count = ps_patch_download(fd, stream);
> fclose(stream);
>
> --
> 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
Ping.
> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: [email protected]
> Cc: [email protected]; [email protected]; Gowtham Anandha
> Babu
> Subject: [PATCH 2/3] shared/gatt-client: Fix usage of freed memory
>
> src/shared/gatt-client.c:472:14: warning: Use of memory after it is freed
> op->success = false;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:627:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:728:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:820:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:888:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:1909:2: warning: Use of memory after it is freed
> complete_read_long_op(op, success, att_ecode);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> src/shared/gatt-client.c:2126:2: warning: Use of memory after it is freed
> complete_write_long_op(op, success, 0, false);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> src/shared/gatt-client.c:2194:6: warning: Use of memory after it is freed
> if (op->callback)
> ^~~~~~~~~~~~
> ---
> src/shared/gatt-client.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index
> 3042a6c..371e89f 100644
> --- a/src/shared/gatt-client.c
> +++ b/src/shared/gatt-client.c
> @@ -449,7 +449,6 @@ next:
>
> util_debug(client->debug_callback, client->debug_data,
> "Failed to start characteristic discovery");
> - discovery_op_unref(op);
> goto failed;
> }
>
> @@ -466,11 +465,11 @@ next:
>
> util_debug(client->debug_callback, client->debug_data,
> "Failed to start included
discovery");
> - discovery_op_unref(op);
>
> failed:
> op->success = false;
> op->complete_func(op, false, att_ecode);
> + discovery_op_unref(op);
> }
>
> struct chrc {
> @@ -618,7 +617,6 @@ next:
>
> util_debug(client->debug_callback, client->debug_data,
> "Failed to start characteristic discovery");
> - discovery_op_unref(op);
>
> failed:
> success = false;
> @@ -626,6 +624,7 @@ failed:
> done:
> op->success = success;
> op->complete_func(op, success, att_ecode);
> + discovery_op_unref(op);
> }
>
> static void discover_chrcs_cb(bool success, uint8_t att_ecode, @@ -719,7
> +718,6 @@ next:
>
> util_debug(client->debug_callback, client->debug_data,
> "Failed to start characteristic discovery");
> - discovery_op_unref(op);
>
> failed:
> success = false;
> @@ -727,6 +725,7 @@ failed:
> done:
> op->success = success;
> op->complete_func(op, success, att_ecode);
> + discovery_op_unref(op);
> }
>
> static void discover_secondary_cb(bool success, uint8_t att_ecode, @@ -
> 814,11 +813,11 @@ next:
>
> util_debug(client->debug_callback, client->debug_data,
> "Failed to start included services
discovery");
> - discovery_op_unref(op);
>
> done:
> op->success = success;
> op->complete_func(op, success, att_ecode);
> + discovery_op_unref(op);
> }
>
> static void discover_primary_cb(bool success, uint8_t att_ecode, @@ -
> 881,12 +880,12 @@ static void discover_primary_cb(bool success, uint8_t
> att_ecode,
>
> util_debug(client->debug_callback, client->debug_data,
> "Failed to start secondary service
discovery");
> - discovery_op_unref(op);
> success = false;
>
> done:
> op->success = success;
> op->complete_func(op, success, att_ecode);
> + discovery_op_unref(op);
> }
>
> static void notify_client_ready(struct bt_gatt_client *client, bool
success,
> @@ -1897,7 +1896,6 @@ static void read_long_cb(uint8_t opcode, const void
> *pdu,
>
> read_long_op_unref))
> return;
>
> - read_long_op_unref(op);
> success = false;
> goto done;
> }
> @@ -1907,6 +1905,7 @@ success:
>
> done:
> complete_read_long_op(op, success, att_ecode);
> + read_long_op_unref(op);
> }
>
> bool bt_gatt_client_read_long_value(struct bt_gatt_client *client, @@ -
> 2109,7 +2108,6 @@ static void handle_next_prep_write(struct
> long_write_op *op)
> prepare_write_cb,
>
> long_write_op_ref(op),
>
> long_write_op_unref)) {
> - long_write_op_unref(op);
> success = false;
> }
>
> @@ -2124,6 +2122,7 @@ static void handle_next_prep_write(struct
> long_write_op *op)
>
> done:
> complete_write_long_op(op, success, 0, false);
> + long_write_op_unref(op);
> }
>
> static void start_next_long_write(struct bt_gatt_client *client) @@
-2141,10
> +2140,10 @@ static void start_next_long_write(struct bt_gatt_client
*client)
>
> handle_next_prep_write(op);
>
> - /* send_next_prep_write adds an extra ref. Unref here to clean up if
> - * necessary, since we also added a ref before pushing to the queue.
> + /* send_next_prep_write adds an extra ref. Unref is handled inside
> + * handle_next_prep_write, since we also added a ref before
> pushing
> + * to the queue.
> */
> - long_write_op_unref(op);
> }
>
> static void execute_write_cb(uint8_t opcode, const void *pdu, uint16_t
> length, @@ -2188,13 +2187,13 @@ static void
> complete_write_long_op(struct long_write_op *op, bool success,
>
> long_write_op_unref))
> return;
>
> - long_write_op_unref(op);
> success = false;
>
> if (op->callback)
> op->callback(success, reliable_error, att_ecode, op-
> >user_data);
>
> start_next_long_write(op->client);
> + long_write_op_unref(op);
> }
>
> static void prepare_write_cb(uint8_t opcode, const void *pdu, uint16_t
> length,
> --
> 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
Ping.
> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: [email protected]
> Cc: [email protected]; [email protected]; Gowtham Anandha
> Babu
> Subject: [PATCH 1/3] shared/gatt-helpers: Fix usage of freed memory
>
> src/shared/gatt-client.c:472:14: warning: Use of memory after it is freed
> op->success = false;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:627:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:728:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:820:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:888:14: warning: Use of memory after it is freed
> op->success = success;
> ~~~~~~~~~~~ ^
> src/shared/gatt-client.c:1909:2: warning: Use of memory after it is freed
> complete_read_long_op(op, success, att_ecode);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> src/shared/gatt-client.c:2126:2: warning: Use of memory after it is freed
> complete_write_long_op(op, success, 0, false);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> src/shared/gatt-client.c:2194:6: warning: Use of memory after it is freed
> if (op->callback)
> ^~~~~~~~~~~~
> ---
> src/shared/gatt-helpers.c | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c index
> c6e179c..a25f1ad 100644
> --- a/src/shared/gatt-helpers.c
> +++ b/src/shared/gatt-helpers.c
> @@ -686,7 +686,6 @@ static void read_by_grp_type_cb(uint8_t opcode,
> const void *pdu,
> discovery_op_unref))
> return;
>
> - discovery_op_unref(op);
> success = false;
> goto done;
> }
> @@ -708,6 +707,8 @@ success:
> done:
> if (op->callback)
> op->callback(success, att_ecode, final_result, op-
> >user_data);
> +
> + discovery_op_unref(op);
> }
>
> static void find_by_type_val_cb(uint8_t opcode, const void *pdu, @@ -
> 766,7 +767,6 @@ static void find_by_type_val_cb(uint8_t opcode, const void
> *pdu,
> discovery_op_unref))
> return;
>
> - discovery_op_unref(op);
> success = false;
> goto done;
> }
> @@ -779,6 +779,8 @@ success:
> done:
> if (op->callback)
> op->callback(success, att_ecode, final_result, op-
> >user_data);
> +
> + discovery_op_unref(op);
> }
>
> static bool discover_services(struct bt_att *att, bt_uuid_t *uuid, @@
-977,7
> +979,6 @@ static void read_included_cb(uint8_t opcode, const void *pdu,
> discovery_op_ref(op), discovery_op_unref))
> return;
>
> - discovery_op_unref(op);
> success = false;
> goto done;
> }
> @@ -997,6 +998,8 @@ static void read_included_cb(uint8_t opcode, const
> void *pdu,
> done:
> if (op->callback)
> op->callback(success, att_ecode, final_result, op-
> >user_data);
> +
> + discovery_op_unref(op);
> }
>
> static void read_included(struct read_incl_data *data) @@ -1014,10
> +1017,10 @@ static void read_included(struct read_incl_data *data)
>
> read_included_unref))
> return;
>
> - read_included_unref(data);
> -
> if (op->callback)
> op->callback(false, 0, NULL, data->op->user_data);
> +
> + read_included_unref(data);
> }
>
> static void discover_included_cb(uint8_t opcode, const void *pdu, @@ -
> 1099,7 +1102,6 @@ static void discover_included_cb(uint8_t opcode, const
> void *pdu,
> discovery_op_unref))
> return;
>
> - discovery_op_unref(op);
> success = false;
> goto failed;
> }
> @@ -1111,6 +1113,8 @@ done:
> failed:
> if (op->callback)
> op->callback(success, att_ecode, final_result, op-
> >user_data);
> +
> + discovery_op_unref(op);
> }
>
> bool bt_gatt_discover_included_services(struct bt_att *att, @@ -1213,7
> +1217,6 @@ static void discover_chrcs_cb(uint8_t opcode, const void *pdu,
> discovery_op_unref))
> return;
>
> - discovery_op_unref(op);
> success = false;
> goto done;
> }
> @@ -1226,6 +1229,8 @@ done:
> if (op->callback)
> op->callback(success, att_ecode, final_result,
> op->user_data);
> +
> + discovery_op_unref(op);
> }
>
> bool bt_gatt_discover_characteristics(struct bt_att *att, @@ -1321,7
+1326,6
> @@ static void read_by_type_cb(uint8_t opcode, const void *pdu,
> discovery_op_unref))
> return;
>
> - discovery_op_unref(op);
> success = false;
> goto done;
> }
> @@ -1332,6 +1336,8 @@ done:
> if (op->callback)
> op->callback(success, att_ecode, success ? op->result_head :
> NULL, op-
> >user_data);
> +
> + discovery_op_unref(op);
> }
>
> bool bt_gatt_read_by_type(struct bt_att *att, uint16_t start, uint16_t
end,
> @@ -1439,7 +1445,6 @@ static void discover_descs_cb(uint8_t opcode,
> const void *pdu,
> discovery_op_unref))
> return;
>
> - discovery_op_unref(op);
> success = false;
> goto done;
> }
> @@ -1451,6 +1456,8 @@ success:
> done:
> if (op->callback)
> op->callback(success, att_ecode, final_result, op-
> >user_data);
> +
> + discovery_op_unref(op);
> }
>
> bool bt_gatt_discover_descriptors(struct bt_att *att,
> --
> 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
Ping.
> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: [email protected]
> Cc: [email protected]; [email protected]; Gowtham Anandha
> Babu
> Subject: [PATCH 0/3] Fix memory issue and trivial code cleaup
>
> In gatt-client and gatt-helpers, the variables are accessed even after it
is
> freed. Making the unref at appropriate places solved the issues.
>
> In tools, removed dead code warnings.
>
> Gowtham Anandha Babu (3):
> shared/gatt-helpers: Fix usage of freed memory
> shared/gatt-client: Fix usage of freed memory
> tools/hciattach_ath3k: Remove dead code warnings
>
> src/shared/gatt-client.c | 23 +++++++++++------------ src/shared/gatt-
> helpers.c | 25 ++++++++++++++++---------
> tools/hciattach_ath3k.c | 11 +----------
> 3 files changed, 28 insertions(+), 31 deletions(-)
>
> --
> 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
src/shared/gatt-client.c:472:14: warning: Use of memory after it is freed
op->success = false;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:627:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:728:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:820:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:888:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:1909:2: warning: Use of memory after it is freed
complete_read_long_op(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2126:2: warning: Use of memory after it is freed
complete_write_long_op(op, success, 0, false);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2194:6: warning: Use of memory after it is freed
if (op->callback)
^~~~~~~~~~~~
---
src/shared/gatt-client.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 3042a6c..371e89f 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -449,7 +449,6 @@ next:
util_debug(client->debug_callback, client->debug_data,
"Failed to start characteristic discovery");
- discovery_op_unref(op);
goto failed;
}
@@ -466,11 +465,11 @@ next:
util_debug(client->debug_callback, client->debug_data,
"Failed to start included discovery");
- discovery_op_unref(op);
failed:
op->success = false;
op->complete_func(op, false, att_ecode);
+ discovery_op_unref(op);
}
struct chrc {
@@ -618,7 +617,6 @@ next:
util_debug(client->debug_callback, client->debug_data,
"Failed to start characteristic discovery");
- discovery_op_unref(op);
failed:
success = false;
@@ -626,6 +624,7 @@ failed:
done:
op->success = success;
op->complete_func(op, success, att_ecode);
+ discovery_op_unref(op);
}
static void discover_chrcs_cb(bool success, uint8_t att_ecode,
@@ -719,7 +718,6 @@ next:
util_debug(client->debug_callback, client->debug_data,
"Failed to start characteristic discovery");
- discovery_op_unref(op);
failed:
success = false;
@@ -727,6 +725,7 @@ failed:
done:
op->success = success;
op->complete_func(op, success, att_ecode);
+ discovery_op_unref(op);
}
static void discover_secondary_cb(bool success, uint8_t att_ecode,
@@ -814,11 +813,11 @@ next:
util_debug(client->debug_callback, client->debug_data,
"Failed to start included services discovery");
- discovery_op_unref(op);
done:
op->success = success;
op->complete_func(op, success, att_ecode);
+ discovery_op_unref(op);
}
static void discover_primary_cb(bool success, uint8_t att_ecode,
@@ -881,12 +880,12 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
util_debug(client->debug_callback, client->debug_data,
"Failed to start secondary service discovery");
- discovery_op_unref(op);
success = false;
done:
op->success = success;
op->complete_func(op, success, att_ecode);
+ discovery_op_unref(op);
}
static void notify_client_ready(struct bt_gatt_client *client, bool success,
@@ -1897,7 +1896,6 @@ static void read_long_cb(uint8_t opcode, const void *pdu,
read_long_op_unref))
return;
- read_long_op_unref(op);
success = false;
goto done;
}
@@ -1907,6 +1905,7 @@ success:
done:
complete_read_long_op(op, success, att_ecode);
+ read_long_op_unref(op);
}
bool bt_gatt_client_read_long_value(struct bt_gatt_client *client,
@@ -2109,7 +2108,6 @@ static void handle_next_prep_write(struct long_write_op *op)
prepare_write_cb,
long_write_op_ref(op),
long_write_op_unref)) {
- long_write_op_unref(op);
success = false;
}
@@ -2124,6 +2122,7 @@ static void handle_next_prep_write(struct long_write_op *op)
done:
complete_write_long_op(op, success, 0, false);
+ long_write_op_unref(op);
}
static void start_next_long_write(struct bt_gatt_client *client)
@@ -2141,10 +2140,10 @@ static void start_next_long_write(struct bt_gatt_client *client)
handle_next_prep_write(op);
- /* send_next_prep_write adds an extra ref. Unref here to clean up if
- * necessary, since we also added a ref before pushing to the queue.
+ /* send_next_prep_write adds an extra ref. Unref is handled inside
+ * handle_next_prep_write, since we also added a ref before pushing
+ * to the queue.
*/
- long_write_op_unref(op);
}
static void execute_write_cb(uint8_t opcode, const void *pdu, uint16_t length,
@@ -2188,13 +2187,13 @@ static void complete_write_long_op(struct long_write_op *op, bool success,
long_write_op_unref))
return;
- long_write_op_unref(op);
success = false;
if (op->callback)
op->callback(success, reliable_error, att_ecode, op->user_data);
start_next_long_write(op->client);
+ long_write_op_unref(op);
}
static void prepare_write_cb(uint8_t opcode, const void *pdu, uint16_t length,
--
1.9.1
tools/hciattach_ath3k.c:848:3: warning: Value stored to 'err' is never read
err = 0;
^ ~
tools/hciattach_ath3k.c:852:3: warning: Value stored to 'err' is never read
err = 0;
^ ~
---
tools/hciattach_ath3k.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index 23208c6..d31732e 100644
--- a/tools/hciattach_ath3k.c
+++ b/tools/hciattach_ath3k.c
@@ -840,17 +840,8 @@ static int ath_ps_download(int fd)
goto download_cmplete;
}
- /*
- * It is not necessary that Patch file be available,
- * continue with PS Operations if patch file is not available.
- */
- if (patch_file[0] == '\0')
- err = 0;
-
stream = fopen(patch_file, "r");
- if (!stream)
- err = 0;
- else {
+ if(stream) {
patch_count = ps_patch_download(fd, stream);
fclose(stream);
--
1.9.1
src/shared/gatt-client.c:472:14: warning: Use of memory after it is freed
op->success = false;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:627:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:728:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:820:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:888:14: warning: Use of memory after it is freed
op->success = success;
~~~~~~~~~~~ ^
src/shared/gatt-client.c:1909:2: warning: Use of memory after it is freed
complete_read_long_op(op, success, att_ecode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2126:2: warning: Use of memory after it is freed
complete_write_long_op(op, success, 0, false);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/gatt-client.c:2194:6: warning: Use of memory after it is freed
if (op->callback)
^~~~~~~~~~~~
---
src/shared/gatt-helpers.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
index c6e179c..a25f1ad 100644
--- a/src/shared/gatt-helpers.c
+++ b/src/shared/gatt-helpers.c
@@ -686,7 +686,6 @@ static void read_by_grp_type_cb(uint8_t opcode, const void *pdu,
discovery_op_unref))
return;
- discovery_op_unref(op);
success = false;
goto done;
}
@@ -708,6 +707,8 @@ success:
done:
if (op->callback)
op->callback(success, att_ecode, final_result, op->user_data);
+
+ discovery_op_unref(op);
}
static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
@@ -766,7 +767,6 @@ static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
discovery_op_unref))
return;
- discovery_op_unref(op);
success = false;
goto done;
}
@@ -779,6 +779,8 @@ success:
done:
if (op->callback)
op->callback(success, att_ecode, final_result, op->user_data);
+
+ discovery_op_unref(op);
}
static bool discover_services(struct bt_att *att, bt_uuid_t *uuid,
@@ -977,7 +979,6 @@ static void read_included_cb(uint8_t opcode, const void *pdu,
discovery_op_ref(op), discovery_op_unref))
return;
- discovery_op_unref(op);
success = false;
goto done;
}
@@ -997,6 +998,8 @@ static void read_included_cb(uint8_t opcode, const void *pdu,
done:
if (op->callback)
op->callback(success, att_ecode, final_result, op->user_data);
+
+ discovery_op_unref(op);
}
static void read_included(struct read_incl_data *data)
@@ -1014,10 +1017,10 @@ static void read_included(struct read_incl_data *data)
read_included_unref))
return;
- read_included_unref(data);
-
if (op->callback)
op->callback(false, 0, NULL, data->op->user_data);
+
+ read_included_unref(data);
}
static void discover_included_cb(uint8_t opcode, const void *pdu,
@@ -1099,7 +1102,6 @@ static void discover_included_cb(uint8_t opcode, const void *pdu,
discovery_op_unref))
return;
- discovery_op_unref(op);
success = false;
goto failed;
}
@@ -1111,6 +1113,8 @@ done:
failed:
if (op->callback)
op->callback(success, att_ecode, final_result, op->user_data);
+
+ discovery_op_unref(op);
}
bool bt_gatt_discover_included_services(struct bt_att *att,
@@ -1213,7 +1217,6 @@ static void discover_chrcs_cb(uint8_t opcode, const void *pdu,
discovery_op_unref))
return;
- discovery_op_unref(op);
success = false;
goto done;
}
@@ -1226,6 +1229,8 @@ done:
if (op->callback)
op->callback(success, att_ecode, final_result,
op->user_data);
+
+ discovery_op_unref(op);
}
bool bt_gatt_discover_characteristics(struct bt_att *att,
@@ -1321,7 +1326,6 @@ static void read_by_type_cb(uint8_t opcode, const void *pdu,
discovery_op_unref))
return;
- discovery_op_unref(op);
success = false;
goto done;
}
@@ -1332,6 +1336,8 @@ done:
if (op->callback)
op->callback(success, att_ecode, success ? op->result_head :
NULL, op->user_data);
+
+ discovery_op_unref(op);
}
bool bt_gatt_read_by_type(struct bt_att *att, uint16_t start, uint16_t end,
@@ -1439,7 +1445,6 @@ static void discover_descs_cb(uint8_t opcode, const void *pdu,
discovery_op_unref))
return;
- discovery_op_unref(op);
success = false;
goto done;
}
@@ -1451,6 +1456,8 @@ success:
done:
if (op->callback)
op->callback(success, att_ecode, final_result, op->user_data);
+
+ discovery_op_unref(op);
}
bool bt_gatt_discover_descriptors(struct bt_att *att,
--
1.9.1