Re: [PATCH] android/tester: Fix valgrind memory warnings

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

 



Hi Andrei,

> From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>
> 
> Free device structure allocated during open_bluetooth().
> ---
>  android/android-tester.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/android/android-tester.c b/android/android-tester.c
> index 7d7ed88..6007797 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -109,6 +109,7 @@ struct test_data {
>  	const void *test_data;
>  	pid_t bluetoothd_pid;
>  
> +	hw_device_t *device;
>  	const bt_interface_t *if_bluetooth;
>  	const btsock_interface_t *if_sock;
>  
> @@ -838,6 +839,8 @@ static void setup(struct test_data *data)
>  		return;
>  	}
>  
> +	data->device = device;
> +
>  	data->if_bluetooth = ((bluetooth_device_t *)
>  					device)->get_bluetooth_interface();
>  	if (!data->if_bluetooth) {
> @@ -882,6 +885,9 @@ static void teardown(const void *test_data)
>  		data->if_bluetooth = NULL;
>  	}
>  
> +	if (data->device)
> +		free(data->device);

There is no need to check pointer before passing it to free().

> +
>  	if (data->bluetoothd_pid)
>  		waitpid(data->bluetoothd_pid, NULL, 0);
>  
> 

-- 
BR
Szymon Janc


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