linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] android/avctp: Fix reference counting
@ 2015-03-27 22:48 Szymon Janc
  2015-03-30 10:03 ` Szymon Janc
  0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2015-03-27 22:48 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Drop extra reference before exiting function.
---
V2: get ref before loop and drop after

 android/avctp.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/android/avctp.c b/android/avctp.c
index d1d2f95..6d7d8cf 100644
--- a/android/avctp.c
+++ b/android/avctp.c
@@ -775,6 +775,8 @@ static void control_response(struct avctp_channel *control,
 								control);
 	}
 
+	avctp_ref(control->session);
+
 	for (l = control->processed; l; l = l->next) {
 		p = l->data;
 		req = p->data;
@@ -788,15 +790,15 @@ static void control_response(struct avctp_channel *control,
 						avc->subunit_type,
 						operands, operand_count,
 						req->user_data))
-			return;
+			break;
 
 		control->processed = g_slist_remove(control->processed, p);
 		pending_destroy(p, NULL);
 
-		avctp_unref(control->session);
-
-		return;
+		break;
 	}
+
+	avctp_unref(control->session);
 }
 
 static void browsing_response(struct avctp_channel *browsing,
@@ -823,6 +825,8 @@ static void browsing_response(struct avctp_channel *browsing,
 								browsing);
 	}
 
+	avctp_ref(browsing->session);
+
 	for (l = browsing->processed; l; l = l->next) {
 		p = l->data;
 		req = p->data;
@@ -830,17 +834,17 @@ static void browsing_response(struct avctp_channel *browsing,
 		if (p->transaction != avctp->transaction)
 			continue;
 
-		avctp_ref(browsing->session);
-
 		if (req->func && req->func(browsing->session, operands,
 						operand_count, req->user_data))
-			return;
+			break;
 
 		browsing->processed = g_slist_remove(browsing->processed, p);
 		pending_destroy(p, NULL);
 
-		return;
+		break;
 	}
+
+	avctp_unref(browsing->session);
 }
 
 static gboolean session_browsing_cb(GIOChannel *chan, GIOCondition cond,
-- 
1.9.3


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

* Re: [PATCH v2] android/avctp: Fix reference counting
  2015-03-27 22:48 [PATCH v2] android/avctp: Fix reference counting Szymon Janc
@ 2015-03-30 10:03 ` Szymon Janc
  0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2015-03-30 10:03 UTC (permalink / raw)
  To: linux-bluetooth

On Friday 27 of March 2015 23:48:55 Szymon Janc wrote:
> Drop extra reference before exiting function.
> ---
> V2: get ref before loop and drop after
> 
>  android/avctp.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/android/avctp.c b/android/avctp.c
> index d1d2f95..6d7d8cf 100644
> --- a/android/avctp.c
> +++ b/android/avctp.c
> @@ -775,6 +775,8 @@ static void control_response(struct avctp_channel
> *control, control);
>  	}
> 
> +	avctp_ref(control->session);
> +
>  	for (l = control->processed; l; l = l->next) {
>  		p = l->data;
>  		req = p->data;
> @@ -788,15 +790,15 @@ static void control_response(struct avctp_channel
> *control, avc->subunit_type,
>  						operands, operand_count,
>  						req->user_data))
> -			return;
> +			break;
> 
>  		control->processed = g_slist_remove(control->processed, p);
>  		pending_destroy(p, NULL);
> 
> -		avctp_unref(control->session);
> -
> -		return;
> +		break;
>  	}
> +
> +	avctp_unref(control->session);
>  }
> 
>  static void browsing_response(struct avctp_channel *browsing,
> @@ -823,6 +825,8 @@ static void browsing_response(struct avctp_channel
> *browsing, browsing);
>  	}
> 
> +	avctp_ref(browsing->session);
> +
>  	for (l = browsing->processed; l; l = l->next) {
>  		p = l->data;
>  		req = p->data;
> @@ -830,17 +834,17 @@ static void browsing_response(struct avctp_channel
> *browsing, if (p->transaction != avctp->transaction)
>  			continue;
> 
> -		avctp_ref(browsing->session);
> -
>  		if (req->func && req->func(browsing->session, operands,
>  						operand_count, req->user_data))
> -			return;
> +			break;
> 
>  		browsing->processed = g_slist_remove(browsing->processed, p);
>  		pending_destroy(p, NULL);
> 
> -		return;
> +		break;
>  	}
> +
> +	avctp_unref(browsing->session);
>  }
> 
>  static gboolean session_browsing_cb(GIOChannel *chan, GIOCondition cond,

Applied.

-- 
BR
Szymon Janc

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

end of thread, other threads:[~2015-03-30 10:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-27 22:48 [PATCH v2] android/avctp: Fix reference counting Szymon Janc
2015-03-30 10:03 ` Szymon Janc

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).