2011-07-15 11:38:31

by Arkadiusz Lichwa

[permalink] [raw]
Subject: [PATCH] Fix mem leak in sap plugin

When dropping rfcomm channel to sap server, the component's channel
cleanup process doesn't release assigned glib channel resources.
---
sap/server.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/sap/server.c b/sap/server.c
index c55aa6e..8bd8fe1 100644
--- a/sap/server.c
+++ b/sap/server.c
@@ -1122,7 +1122,6 @@ static void sap_io_destroy(void *data)
conn->state == SAP_STATE_GRACEFUL_DISCONNECT)
sap_disconnect_req(NULL, 1);

- conn->io = NULL;
sap_conn_remove(conn);
}
}
--
1.7.6



2011-07-28 07:56:31

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Fix mem leak in sap plugin

Hi Arek,

On Fri, Jul 15, 2011, Arek Lichwa wrote:
> When dropping rfcomm channel to sap server, the component's channel
> cleanup process doesn't release assigned glib channel resources.
> ---
> sap/server.c | 1 -
> 1 files changed, 0 insertions(+), 1 deletions(-)

Applied. I had to actually look at the code to determine that the patch
is correct since your commit message doesn't really explain the
situation clearly enough (which is also why you got initial doubts from
Luiz).

Johan

2011-07-15 12:31:59

by Arkadiusz Lichwa

[permalink] [raw]
Subject: RE: [PATCH] Fix mem leak in sap plugin

Hi Luiz
>Hi,
>
>On Fri, Jul 15, 2011 at 2:38 PM, Arek Lichwa <[email protected]>
>wrote:
>> When dropping rfcomm channel to sap server, the component's channel
>> cleanup process doesn't release assigned glib channel resources.
>> ---
>> ?sap/server.c | ? ?1 -
>> ?1 files changed, 0 insertions(+), 1 deletions(-)
>>
>> diff --git a/sap/server.c b/sap/server.c
>> index c55aa6e..8bd8fe1 100644
>> --- a/sap/server.c
>> +++ b/sap/server.c
>> @@ -1122,7 +1122,6 @@ static void sap_io_destroy(void *data)
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?conn->state ==
>SAP_STATE_GRACEFUL_DISCONNECT)
>> ? ? ? ? ? ? ? ? ? ? ? ?sap_disconnect_req(NULL, 1);
>>
>> - ? ? ? ? ? ? ? conn->io = NULL;
>> ? ? ? ? ? ? ? ?sap_conn_remove(conn);
>> ? ? ? ?}
>> ?}
>> --
>> 1.7.6
>
>It doesn't seems this release any memory, maybe the problem is not a
>memory leak but an invalid access to freed memory?

Actually the realese/cleanup process of glib resource isn't triggered.
It would when last reference to conn->io get 0. It's been triggered in
sap_conn_remove() but conn->io already got null before that.
So it needs better description ?

/Arek
>
>--
>Luiz Augusto von Dentz

2011-07-15 12:13:44

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] Fix mem leak in sap plugin

Hi,

On Fri, Jul 15, 2011 at 2:38 PM, Arek Lichwa <[email protected]> wrote:
> When dropping rfcomm channel to sap server, the component's channel
> cleanup process doesn't release assigned glib channel resources.
> ---
> ?sap/server.c | ? ?1 -
> ?1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/sap/server.c b/sap/server.c
> index c55aa6e..8bd8fe1 100644
> --- a/sap/server.c
> +++ b/sap/server.c
> @@ -1122,7 +1122,6 @@ static void sap_io_destroy(void *data)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?conn->state == SAP_STATE_GRACEFUL_DISCONNECT)
> ? ? ? ? ? ? ? ? ? ? ? ?sap_disconnect_req(NULL, 1);
>
> - ? ? ? ? ? ? ? conn->io = NULL;
> ? ? ? ? ? ? ? ?sap_conn_remove(conn);
> ? ? ? ?}
> ?}
> --
> 1.7.6

It doesn't seems this release any memory, maybe the problem is not a
memory leak but an invalid access to freed memory?

--
Luiz Augusto von Dentz