linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH  0/3] Fix memory issue and trivial code cleaup
@ 2015-01-14  9:57 Gowtham Anandha Babu
  2015-01-14  9:57 ` [PATCH 1/3] shared/gatt-helpers: Fix usage of freed memory Gowtham Anandha Babu
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-14  9:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs, Gowtham Anandha Babu

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


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

* [PATCH  1/3] shared/gatt-helpers: Fix usage of freed memory
  2015-01-14  9:57 [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
@ 2015-01-14  9:57 ` Gowtham Anandha Babu
  2015-01-20  9:34   ` Gowtham Anandha Babu
  2015-01-14  9:57 ` [PATCH 2/3] shared/gatt-client: " Gowtham Anandha Babu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-14  9:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs, Gowtham Anandha Babu

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


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

* [PATCH  2/3] shared/gatt-client: Fix usage of freed memory
  2015-01-14  9:57 [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
  2015-01-14  9:57 ` [PATCH 1/3] shared/gatt-helpers: Fix usage of freed memory Gowtham Anandha Babu
@ 2015-01-14  9:57 ` Gowtham Anandha Babu
  2015-01-20  9:35   ` Gowtham Anandha Babu
  2015-01-14  9:57 ` [PATCH 3/3] tools/hciattach_ath3k: Remove dead code warnings Gowtham Anandha Babu
  2015-01-20  9:34 ` [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
  3 siblings, 1 reply; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-14  9:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs, Gowtham Anandha Babu

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


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

* [PATCH  3/3] tools/hciattach_ath3k: Remove dead code warnings
  2015-01-14  9:57 [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
  2015-01-14  9:57 ` [PATCH 1/3] shared/gatt-helpers: Fix usage of freed memory Gowtham Anandha Babu
  2015-01-14  9:57 ` [PATCH 2/3] shared/gatt-client: " Gowtham Anandha Babu
@ 2015-01-14  9:57 ` Gowtham Anandha Babu
  2015-01-20  9:35   ` Gowtham Anandha Babu
  2015-01-20  9:34 ` [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
  3 siblings, 1 reply; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-14  9:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs, Gowtham Anandha Babu

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


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

* RE: [PATCH  0/3] Fix memory issue and trivial code cleaup
  2015-01-14  9:57 [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
                   ` (2 preceding siblings ...)
  2015-01-14  9:57 ` [PATCH 3/3] tools/hciattach_ath3k: Remove dead code warnings Gowtham Anandha Babu
@ 2015-01-20  9:34 ` Gowtham Anandha Babu
  2015-01-22  9:03   ` Luiz Augusto von Dentz
  3 siblings, 1 reply; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-20  9:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs

Ping.

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: linux-bluetooth@vger.kernel.org
> Cc: bharat.panda@samsung.com; cpgs@samsung.com; 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 majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


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

* RE: [PATCH  1/3] shared/gatt-helpers: Fix usage of freed memory
  2015-01-14  9:57 ` [PATCH 1/3] shared/gatt-helpers: Fix usage of freed memory Gowtham Anandha Babu
@ 2015-01-20  9:34   ` Gowtham Anandha Babu
  0 siblings, 0 replies; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-20  9:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs

Ping.

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: linux-bluetooth@vger.kernel.org
> Cc: bharat.panda@samsung.com; cpgs@samsung.com; 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 majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


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

* RE: [PATCH  2/3] shared/gatt-client: Fix usage of freed memory
  2015-01-14  9:57 ` [PATCH 2/3] shared/gatt-client: " Gowtham Anandha Babu
@ 2015-01-20  9:35   ` Gowtham Anandha Babu
  0 siblings, 0 replies; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-20  9:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs

Ping.

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: linux-bluetooth@vger.kernel.org
> Cc: bharat.panda@samsung.com; cpgs@samsung.com; 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 majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


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

* RE: [PATCH  3/3] tools/hciattach_ath3k: Remove dead code warnings
  2015-01-14  9:57 ` [PATCH 3/3] tools/hciattach_ath3k: Remove dead code warnings Gowtham Anandha Babu
@ 2015-01-20  9:35   ` Gowtham Anandha Babu
  0 siblings, 0 replies; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-20  9:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: bharat.panda, cpgs

Ping.

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Gowtham Anandha Babu
> Sent: Wednesday, January 14, 2015 3:28 PM
> To: linux-bluetooth@vger.kernel.org
> Cc: bharat.panda@samsung.com; cpgs@samsung.com; 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 majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH 0/3] Fix memory issue and trivial code cleaup
  2015-01-20  9:34 ` [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
@ 2015-01-22  9:03   ` Luiz Augusto von Dentz
  2015-01-27  8:58     ` Gowtham Anandha Babu
  0 siblings, 1 reply; 10+ messages in thread
From: Luiz Augusto von Dentz @ 2015-01-22  9:03 UTC (permalink / raw)
  To: Gowtham Anandha Babu; +Cc: linux-bluetooth@vger.kernel.org, Bharat Panda, cpgs

Hi Gowtham,

On Tue, Jan 20, 2015 at 11:34 AM, Gowtham Anandha Babu
<gowtham.ab@samsung.com> wrote:
> Ping.
>
>> -----Original Message-----
>> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
>> owner@vger.kernel.org] On Behalf Of Gowtham Anandha Babu
>> Sent: Wednesday, January 14, 2015 3:28 PM
>> To: linux-bluetooth@vger.kernel.org
>> Cc: bharat.panda@samsung.com; cpgs@samsung.com; 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

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

* RE: [PATCH 0/3] Fix memory issue and trivial code cleaup
  2015-01-22  9:03   ` Luiz Augusto von Dentz
@ 2015-01-27  8:58     ` Gowtham Anandha Babu
  0 siblings, 0 replies; 10+ messages in thread
From: Gowtham Anandha Babu @ 2015-01-27  8:58 UTC (permalink / raw)
  To: 'Luiz Augusto von Dentz'
  Cc: linux-bluetooth, 'Bharat Panda', cpgs

Hi Luiz,

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Luiz Augusto von Dentz
> Sent: Thursday, January 22, 2015 2:33 PM
> To: Gowtham Anandha Babu
> Cc: linux-bluetooth@vger.kernel.org; Bharat Panda; cpgs@samsung.com
> 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
> <gowtham.ab@samsung.com> wrote:
> > Ping.
> >
> >> -----Original Message-----
> >> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> >> owner@vger.kernel.org] On Behalf Of Gowtham Anandha Babu
> >> Sent: Wednesday, January 14, 2015 3:28 PM
> >> To: linux-bluetooth@vger.kernel.org
> >> Cc: bharat.panda@samsung.com; cpgs@samsung.com; 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 majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2015-01-27  8:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14  9:57 [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
2015-01-14  9:57 ` [PATCH 1/3] shared/gatt-helpers: Fix usage of freed memory Gowtham Anandha Babu
2015-01-20  9:34   ` Gowtham Anandha Babu
2015-01-14  9:57 ` [PATCH 2/3] shared/gatt-client: " Gowtham Anandha Babu
2015-01-20  9:35   ` Gowtham Anandha Babu
2015-01-14  9:57 ` [PATCH 3/3] tools/hciattach_ath3k: Remove dead code warnings Gowtham Anandha Babu
2015-01-20  9:35   ` Gowtham Anandha Babu
2015-01-20  9:34 ` [PATCH 0/3] Fix memory issue and trivial code cleaup Gowtham Anandha Babu
2015-01-22  9:03   ` Luiz Augusto von Dentz
2015-01-27  8:58     ` Gowtham Anandha Babu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).