Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Anchit Narang <anchit.n@samsung.com>
Cc: linux-bluetooth@vger.kernel.org, sachin.dev@samsung.com
Subject: Re: [PATCH] tools/hciconfig:Fixed Memory Leak
Date: Mon, 27 Jul 2015 12:07:30 +0200	[thread overview]
Message-ID: <5618947.PXfyCffJ71@leonov> (raw)
In-Reply-To: <1437989799-17394-1-git-send-email-anchit.n@samsung.com>

Hi Anchit,

On Monday 27 of July 2015 15:06:39 Anchit Narang wrote:
> Freed memory allocated to structure hci_dev_list_req to avoid memory leak
> ---
>  tools/hciconfig.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/hciconfig.c b/tools/hciconfig.c
> index 6397e71..0738b53 100644
> --- a/tools/hciconfig.c
> +++ b/tools/hciconfig.c
> @@ -69,6 +69,10 @@ static void print_dev_list(int ctl, int flags)
> 
>  	if (ioctl(ctl, HCIGETDEVLIST, (void *) dl) < 0) {
>  		perror("Can't get device list");
> +
> +		if (dl)
> +		    free(dl);
> +

There is no need to check for non-NULL pointer as free() handles this 
internally.

>  		exit(1);
>  	}
> 
> @@ -78,6 +82,9 @@ static void print_dev_list(int ctl, int flags)
>  			continue;
>  		print_dev_info(ctl, &di);
>  	}
> +
> +	if (dl)
> +	    free(dl);

Same here.

>  }
> 
>  static void print_pkt_type(struct hci_dev_info *di)

-- 
BR
Szymon Janc

      reply	other threads:[~2015-07-27 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27  9:36 [PATCH] tools/hciconfig:Fixed Memory Leak Anchit Narang
2015-07-27 10:07 ` Szymon Janc [this message]

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=5618947.PXfyCffJ71@leonov \
    --to=szymon.janc@tieto.com \
    --cc=anchit.n@samsung.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=sachin.dev@samsung.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox