Re: [PATCH] gatt: Fix memory leak in profile_add

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrei,

On Tue, May 19, 2015, Andrei Emeltchenko wrote:
> Cleanup memory correctly.
> ---
>  src/gatt-database.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gatt-database.c b/src/gatt-database.c
> index dd80aa0..ca514db 100644
> --- a/src/gatt-database.c
> +++ b/src/gatt-database.c
> @@ -2299,8 +2299,11 @@ static int profile_add(struct external_profile *profile, const char *uuid)
>  		return -ENOMEM;
>  
>  	p->remote_uuid = (const void *) g_strdup(uuid);
> -	if (!p->remote_uuid)
> +	if (!p->remote_uuid) {
> +		g_free((void *) p->name);
> +		free((void *) p);
>  		return -ENOMEM;
> +	}
>  
>  	p->auto_connect = true;

Applied, but we need to do something about the 'const char *' members of
btd_profile. If we're using them to store non-const values they
shouldn't be declared const to begin with. If someone wants to
contribute this change the btd_profile the definition should also have a
comment that the management of these values is left to the higher-level
implementation (i.e. nothing needed for the stack based ones, and
g_free/free needed for ext_profile and the GATT stuff).

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux