linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels
@ 2012-02-07  9:33 Santiago Carot-Nemesio
  2012-02-07 10:53 ` Anderson Lizardo
  0 siblings, 1 reply; 7+ messages in thread
From: Santiago Carot-Nemesio @ 2012-02-07  9:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Santiago Carot-Nemesio

Channel is not being released when the channel is attached over
an uninitialized GATT server.
---
 src/attrib-server.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 2995167..a23d5d2 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -1020,8 +1020,14 @@ guint attrib_channel_attach(GAttrib *attrib, gboolean out)
 	}
 
 	server = find_gatt_server(&channel->src);
-	if (server == NULL)
+	if (server == NULL) {
+		char src[18];
+
+		ba2str(&channel->src, src);
+		error("Not GATT server found in %s", src);
+		g_free(channel);
 		return 0;
+	}
 
 	channel->server = server;
 
-- 
1.7.9


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

* Re: [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels
  2012-02-07  9:33 Santiago Carot-Nemesio
@ 2012-02-07 10:53 ` Anderson Lizardo
  0 siblings, 0 replies; 7+ messages in thread
From: Anderson Lizardo @ 2012-02-07 10:53 UTC (permalink / raw)
  To: Santiago Carot-Nemesio; +Cc: linux-bluetooth

Hi Santiago,

On Tue, Feb 7, 2012 at 5:33 AM, Santiago Carot-Nemesio
<sancane@gmail.com> wrote:
> Channel is not being released when the channel is attached over
> an uninitialized GATT server.
> ---
>  src/attrib-server.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/src/attrib-server.c b/src/attrib-server.c
> index 2995167..a23d5d2 100644
> --- a/src/attrib-server.c
> +++ b/src/attrib-server.c
> @@ -1020,8 +1020,14 @@ guint attrib_channel_attach(GAttrib *attrib, gboolean out)
>        }
>
>        server = find_gatt_server(&channel->src);
> -       if (server == NULL)
> +       if (server == NULL) {
> +               char src[18];
> +
> +               ba2str(&channel->src, src);
> +               error("Not GATT server found in %s", src);

Looks ok, except for the typo: Not -> No

> +               g_free(channel);
>                return 0;
> +       }
>
>        channel->server = server;
>
> --
> 1.7.9

Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

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

* [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels
@ 2012-02-07 13:26 Santiago Carot-Nemesio
  2012-02-07 13:37 ` [PATCH 2/2] attrib-server: Fix bad error message Santiago Carot-Nemesio
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Santiago Carot-Nemesio @ 2012-02-07 13:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Santiago Carot-Nemesio

Channel is not being released when the channel is attached over
an uninitialized GATT server.
---
 src/attrib-server.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 2995167..e51f695 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -1020,8 +1020,14 @@ guint attrib_channel_attach(GAttrib *attrib, gboolean out)
 	}
 
 	server = find_gatt_server(&channel->src);
-	if (server == NULL)
+	if (server == NULL) {
+		char src[18];
+
+		ba2str(&channel->src, src);
+		error("No GATT server found in %s", src);
+		g_free(channel);
 		return 0;
+	}
 
 	channel->server = server;
 
-- 
1.7.9


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

* [PATCH 2/2] attrib-server: Fix bad error message
  2012-02-07 13:26 [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Santiago Carot-Nemesio
@ 2012-02-07 13:37 ` Santiago Carot-Nemesio
  2012-02-08  8:21 ` [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Andrei Emeltchenko
  2012-02-09 10:45 ` Johan Hedberg
  2 siblings, 0 replies; 7+ messages in thread
From: Santiago Carot-Nemesio @ 2012-02-07 13:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Santiago Carot-Nemesio

---
 src/attrib-server.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index e51f695..93a7b4f 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -171,7 +171,7 @@ static struct gatt_server *find_gatt_server(const bdaddr_t *bdaddr)
 		char addr[18];
 
 		ba2str(bdaddr, addr);
-		error("Not GATT adapter found for address %s", addr);
+		error("No GATT server found in %s", addr);
 		return NULL;
 	}
 
-- 
1.7.9


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

* Re: [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels
  2012-02-07 13:26 [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Santiago Carot-Nemesio
  2012-02-07 13:37 ` [PATCH 2/2] attrib-server: Fix bad error message Santiago Carot-Nemesio
@ 2012-02-08  8:21 ` Andrei Emeltchenko
  2012-02-08  8:47   ` Santiago Carot
  2012-02-09 10:45 ` Johan Hedberg
  2 siblings, 1 reply; 7+ messages in thread
From: Andrei Emeltchenko @ 2012-02-08  8:21 UTC (permalink / raw)
  To: Santiago Carot-Nemesio; +Cc: linux-bluetooth

Hi Santiago,

On Tue, Feb 07, 2012 at 02:26:44PM +0100, Santiago Carot-Nemesio wrote:
> Channel is not being released when the channel is attached over
> an uninitialized GATT server.
> ---
>  src/attrib-server.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/src/attrib-server.c b/src/attrib-server.c
> index 2995167..e51f695 100644
> --- a/src/attrib-server.c
> +++ b/src/attrib-server.c
> @@ -1020,8 +1020,14 @@ guint attrib_channel_attach(GAttrib *attrib, gboolean out)
>  	}
>  
>  	server = find_gatt_server(&channel->src);
> -	if (server == NULL)
> +	if (server == NULL) {
> +		char src[18];

Don't we have a good define for this magic number? I saw it in several
places.

Best regards 
Andrei Emeltchenko 



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

* Re: [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels
  2012-02-08  8:21 ` [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Andrei Emeltchenko
@ 2012-02-08  8:47   ` Santiago Carot
  0 siblings, 0 replies; 7+ messages in thread
From: Santiago Carot @ 2012-02-08  8:47 UTC (permalink / raw)
  To: Andrei Emeltchenko, Santiago Carot-Nemesio, linux-bluetooth

Hi Andrei,

2012/2/8 Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>:
> Hi Santiago,
>
> On Tue, Feb 07, 2012 at 02:26:44PM +0100, Santiago Carot-Nemesio wrote:
>> Channel is not being released when the channel is attached over
>> an uninitialized GATT server.
>> ---
>>  src/attrib-server.c |    8 +++++++-
>>  1 files changed, 7 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/attrib-server.c b/src/attrib-server.c
>> index 2995167..e51f695 100644
>> --- a/src/attrib-server.c
>> +++ b/src/attrib-server.c
>> @@ -1020,8 +1020,14 @@ guint attrib_channel_attach(GAttrib *attrib, gboolean out)
>>       }
>>
>>       server = find_gatt_server(&channel->src);
>> -     if (server == NULL)
>> +     if (server == NULL) {
>> +             char src[18];
>
> Don't we have a good define for this magic number? I saw it in several
> places.
>

That's a good point, I've also seen it in too many places but I don't
know if there is any macro for that, at least I didn't see it.

Regards.

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

* Re: [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels
  2012-02-07 13:26 [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Santiago Carot-Nemesio
  2012-02-07 13:37 ` [PATCH 2/2] attrib-server: Fix bad error message Santiago Carot-Nemesio
  2012-02-08  8:21 ` [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Andrei Emeltchenko
@ 2012-02-09 10:45 ` Johan Hedberg
  2 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2012-02-09 10:45 UTC (permalink / raw)
  To: Santiago Carot-Nemesio; +Cc: linux-bluetooth

Hi Santiago,

On Tue, Feb 07, 2012, Santiago Carot-Nemesio wrote:
> Channel is not being released when the channel is attached over
> an uninitialized GATT server.
> ---
>  src/attrib-server.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)

Both patches have been applied. Thanks.

Johan

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

end of thread, other threads:[~2012-02-09 10:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-07 13:26 [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Santiago Carot-Nemesio
2012-02-07 13:37 ` [PATCH 2/2] attrib-server: Fix bad error message Santiago Carot-Nemesio
2012-02-08  8:21 ` [PATCH 1/2] attrib-server: Fix memory leak attaching attribute channels Andrei Emeltchenko
2012-02-08  8:47   ` Santiago Carot
2012-02-09 10:45 ` Johan Hedberg
  -- strict thread matches above, loose matches on Subject: below --
2012-02-07  9:33 Santiago Carot-Nemesio
2012-02-07 10:53 ` Anderson Lizardo

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