linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix memory leak of unused EIR name
@ 2010-12-20 13:38 Anderson Lizardo
  2010-12-20 15:32 ` [PATCH v2] " anderson.lizardo
  0 siblings, 1 reply; 3+ messages in thread
From: Anderson Lizardo @ 2010-12-20 13:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

There is a code path in btd_event_device_found() where the EIR name is
not used. This requires freeing eir_data.name to avoid a leak.

Additionally, an incorrect use of free() is replaced with g_free().
---
 src/event.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/event.c b/src/event.c
index 3603643..0c11da7 100644
--- a/src/event.c
+++ b/src/event.c
@@ -527,6 +527,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 	/* if found: don't send the name again */
 	dev = adapter_search_found_devices(adapter, &match);
 	if (dev) {
+		g_free(eir_data.name);
 		adapter_update_found_devices(adapter, peer, rssi, class,
 						NULL, NULL, dev->legacy,
 						eir_data.services,
@@ -570,7 +571,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 			name = eir_data.name;
 		} else {
 			if (name)
-				free(eir_data.name);
+				g_free(eir_data.name);
 			else
 				name = eir_data.name;
 		}
-- 
1.7.0.4


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

* [PATCH v2] Fix memory leak of unused EIR name
  2010-12-20 13:38 [PATCH] Fix memory leak of unused EIR name Anderson Lizardo
@ 2010-12-20 15:32 ` anderson.lizardo
  2010-12-20 15:36   ` Johan Hedberg
  0 siblings, 1 reply; 3+ messages in thread
From: anderson.lizardo @ 2010-12-20 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

From: Anderson Lizardo <anderson.lizardo@openbossa.org>

There is a code path in btd_event_device_found() where the EIR name is
not used. This requires freeing eir_data.name to avoid a leak.
---
 src/event.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/event.c b/src/event.c
index 3603643..22f4f72 100644
--- a/src/event.c
+++ b/src/event.c
@@ -527,6 +527,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 	/* if found: don't send the name again */
 	dev = adapter_search_found_devices(adapter, &match);
 	if (dev) {
+		g_free(eir_data.name);
 		adapter_update_found_devices(adapter, peer, rssi, class,
 						NULL, NULL, dev->legacy,
 						eir_data.services,
-- 
1.7.0.4


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

* Re: [PATCH v2] Fix memory leak of unused EIR name
  2010-12-20 15:32 ` [PATCH v2] " anderson.lizardo
@ 2010-12-20 15:36   ` Johan Hedberg
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2010-12-20 15:36 UTC (permalink / raw)
  To: anderson.lizardo; +Cc: linux-bluetooth

Hi Lizardo,

On Mon, Dec 20, 2010, anderson.lizardo@openbossa.org wrote:
> There is a code path in btd_event_device_found() where the EIR name is
> not used. This requires freeing eir_data.name to avoid a leak.
> ---
>  src/event.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)

Thanks. Pushed upstream.

Johan

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

end of thread, other threads:[~2010-12-20 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-20 13:38 [PATCH] Fix memory leak of unused EIR name Anderson Lizardo
2010-12-20 15:32 ` [PATCH v2] " anderson.lizardo
2010-12-20 15:36   ` Johan Hedberg

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