All of lore.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] android/tester: Fix valgrind memory warnings
Date: Fri, 20 Dec 2013 10:12:57 +0100	[thread overview]
Message-ID: <2739769.kltLLfnETe@uw000953> (raw)
In-Reply-To: <1387529782-26462-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> 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



  parent reply	other threads:[~2013-12-20  9:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20  8:56 [PATCH] android/tester: Fix valgrind memory warnings Andrei Emeltchenko
2013-12-20  9:00 ` Andrei Emeltchenko
2013-12-20  9:12 ` Szymon Janc [this message]
2013-12-20  9:30   ` Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2739769.kltLLfnETe@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=Andrei.Emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.