Skip to contentSkip to conversation

attrib-server: Fix memory leak attaching attribute channels

PATCH In review Santiago Carot-Nemesio 2 participants 5 messages Feb 7, 2012 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 attrib-server: Fix memory leak attaching attribute channels

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(-)
src/attrib-server.c +7 -1
index 2995167..a23d5d2 100644
@@ -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;
 
Signature · 1 line
1.7.9
#1 lore raw

PATCH 2/2 attrib-server: Fix bad error message

---
 src/attrib-server.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
src/attrib-server.c +1 -1
index a23d5d2..3d4634f 100644
@@ -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("Not GATT server found in %s", addr);
 		return NULL;
 	}
 
Signature · 1 line
1.7.9
#2 lore raw

Re: [PATCH 2/2] attrib-server: Fix bad error message

Hi Santiago,

Quoted 9 lines · Santiago Carot-Nemesio

---
 src/attrib-server.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
src/attrib-server.c +0 -0
index a23d5d2..3d4634f 100644

src/attrib-server.c static struct gatt_server *find_gatt_server(const bdaddr_t *bdaddr) · line 174

Quoted 5 lines
src/attrib-server.c +1 -1
@@ -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("Not GATT server found in %s", addr);

You can also fix: Not -> No

Quoted 5 lines
src/attrib-server.c +0 -1
                return NULL;
        }
 
--

1.7.9

Best Regards,

Signature · 3 lines
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
#3 lore raw

Re: [PATCH 2/2] attrib-server: Fix bad error message

Hi,

2012/2/7 Anderson Lizardo <[email protected]>:

Quoted 15 lines

Hi Santiago,

Quoted 11 lines · Santiago Carot-Nemesio

---
 src/attrib-server.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
src/attrib-server.c +0 -0
index a23d5d2..3d4634f 100644
@@ -171,7 +171,7 @@ static struct gatt_server *find_gatt_server(const bdaddr_t *bdaddr)
                char addr[18];
 
Quoted 12 lines

src/attrib-server.c static struct gatt_server *find_gatt_server(const bdaddr_t *bdaddr) · line 174

Quoted 3 lines
src/attrib-server.c +1 -1
                ba2str(bdaddr, addr);
-               error("Not GATT adapter found for address %s", addr);
+               error("Not GATT server found in %s", addr);

You can also fix: Not -> No

Quoted 5 lines
src/attrib-server.c +0 -1
                return NULL;
        }
 
--

1.7.9

Ok, ignore these two patches, I'll send another ones ASAP

#4 lore raw
In reply to Santiago Carot-Nemesio

Hi Santiago,

Quoted 11 lines · 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(-)
src/attrib-server.c +0 -0
index 2995167..a23d5d2 100644

src/attrib-server.c guint attrib_channel_attach(GAttrib *attrib, gboolean out) · line 1027

Quoted 9 lines
src/attrib-server.c +5 -1
@@ -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

Quoted 8 lines
src/attrib-server.c +2 -1
+               g_free(channel);
                return 0;
+       }
 
        channel->server = server;
 
--

1.7.9

Best Regards,

Signature · 3 lines
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil