Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv4 09/12] tools: Fix memory leak
Date: Fri, 1 Aug 2014 14:27:05 +0300	[thread overview]
Message-ID: <20140801112703.GC9036@aemeltch-MOBL1> (raw)
In-Reply-To: <20140801112124.GA28357@t440s.P-661HNU-F1>

Hi Johan,

On Fri, Aug 01, 2014 at 02:21:24PM +0300, Johan Hedberg wrote:
> Hi Andrei,
> 
> On Fri, Aug 01, 2014, Andrei Emeltchenko wrote:
> > Hi Johan,
> > 
> > On Fri, Aug 01, 2014 at 01:35:17PM +0300, Johan Hedberg wrote:
> > > Hi Andrei,
> > > 
> > > On Tue, Jul 29, 2014, Andrei Emeltchenko wrote:
> > > > lmpver and hciver are allocated through malloc and need to be freed.
> > > > ---
> > > >  tools/parser/hci.c | 19 ++++++++++++++++---
> > > >  1 file changed, 16 insertions(+), 3 deletions(-)
> > > 
> > > I've applied all 8 patches before this one.
> > > 
> > > > diff --git a/tools/parser/hci.c b/tools/parser/hci.c
> > > > index 351f843..1a639af 100644
> > > > --- a/tools/parser/hci.c
> > > > +++ b/tools/parser/hci.c
> > > > @@ -2445,17 +2445,25 @@ static inline void read_local_version_dump(int level, struct frame *frm)
> > > >  		p_indent(level, frm);
> > > >  		printf("Error: %s\n", status2str(rp->status));
> > > >  	} else {
> > > > +		char *lmpver = lmp_vertostr(rp->lmp_ver);
> > > > +		char *hciver = hci_vertostr(rp->hci_ver);
> > > > +
> > > >  		p_indent(level, frm);
> > > >  		printf("HCI Version: %s (0x%x) HCI Revision: 0x%x\n",
> > > > -					hci_vertostr(rp->hci_ver),
> > > > +					hciver ? hciver : "n/a",
> > > >  					rp->hci_ver, btohs(rp->hci_rev));
> > > >  		p_indent(level, frm);
> > > >  		printf("LMP Version: %s (0x%x) LMP Subversion: 0x%x\n",
> > > > -					lmp_vertostr(rp->lmp_ver),
> > > > +					lmpver ? lmpver : "n/a",
> > > >  					rp->lmp_ver, btohs(rp->lmp_subver));
> > > >  		p_indent(level, frm);
> > > >  		printf("Manufacturer: %s (%d)\n",
> > > >  				bt_compidtostr(manufacturer), manufacturer);
> > > > +
> > > > +		if (lmpver)
> > > > +			bt_free(lmpver);
> > > > +		if (hciver)
> > > > +			bt_free(hciver);
> > > 
> > > These trace back to using malloc (in hci_uint2str) so I suppose free is
> > > more appropriate than bt_free (which should be used for bt_malloc).
> > 
> > OK, I will change it to free(). Shall I also change other similar
> > bt_free() calls which I took as example?
> 
> I'm not sure it's worth bothering with legacy code like this which will
> eventually disappear from the tree.

Those constructions are in hcitool and hciconfig

Best regards 
Andrei Emeltchenko 


  reply	other threads:[~2014-08-01 11:27 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  8:55 [PATCH 1/2] core: Remove unneeded assignment Andrei Emeltchenko
2014-07-17  8:55 ` [PATCH 2/2] android/core: " Andrei Emeltchenko
2014-07-18 13:28 ` [PATCHv2 1/6] core: " Andrei Emeltchenko
2014-07-18 13:28   ` [PATCHv2 2/6] android/core: " Andrei Emeltchenko
2014-07-18 13:28   ` [PATCHv2 3/6] tools/rctest: Remove unneeded return Andrei Emeltchenko
2014-07-18 13:28   ` [PATCHv2 4/6] tools/rctest: Remove dead code Andrei Emeltchenko
2014-07-18 13:28   ` [PATCHv2 5/6] tools/scotest: Remove unneeded return Andrei Emeltchenko
2014-07-18 13:28   ` [PATCHv2 6/6] tools/l2test: " Andrei Emeltchenko
2014-07-28 12:46 ` [PATCHv3 01/11] core: Remove unneeded assignment Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 02/11] android/core: " Andrei Emeltchenko
2014-07-28 13:57     ` Johan Hedberg
2014-07-29  7:42       ` Andrei Emeltchenko
2014-07-29  7:50         ` Johan Hedberg
2014-07-28 12:46   ` [PATCHv3 03/11] tools/rctest: Remove unneeded return Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 04/11] tools/rctest: Remove dead code Andrei Emeltchenko
2014-07-28 13:58     ` Johan Hedberg
2014-07-28 12:46   ` [PATCHv3 05/11] tools/scotest: Remove unneeded return Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 06/11] tools/l2test: " Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 07/11] tools/scotest: Fix double close socket Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 08/11] android/ipc: Remove unneeded check Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 09/11] tools: Fix memory leak Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 10/11] obexd: " Andrei Emeltchenko
2014-07-28 12:46   ` [PATCHv3 11/11] " Andrei Emeltchenko
2014-07-29 14:20 ` [PATCHv4 01/12] core: Remove unneeded assignment Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 02/12] android/core: Use g_clear_error instead of free and assignment Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 03/12] tools/rctest: Remove unneeded return Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 04/12] tools/rctest: Remove dead code Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 05/12] tools/scotest: Remove unneeded return Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 06/12] tools/l2test: " Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 07/12] tools/scotest: Fix double close socket Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 08/12] android/ipc: Remove unneeded check Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 09/12] tools: Fix memory leak Andrei Emeltchenko
2014-08-01 10:35     ` Johan Hedberg
2014-08-01 11:12       ` Andrei Emeltchenko
2014-08-01 11:21         ` Johan Hedberg
2014-08-01 11:27           ` Andrei Emeltchenko [this message]
2014-08-01 11:33             ` Johan Hedberg
2014-08-01 11:54               ` Andrei Emeltchenko
2014-07-29 14:20   ` [PATCHv4 10/12] obexd: " Andrei Emeltchenko
2014-08-01 10:36     ` Johan Hedberg
2014-07-29 14:21   ` [PATCHv4 11/12] " Andrei Emeltchenko
2014-08-01 10:38     ` Johan Hedberg
2014-08-01 11:18       ` [PATCHv4 1/3] tools: " Andrei Emeltchenko
2014-08-01 11:18         ` [PATCHv4 2/3] obexd: " Andrei Emeltchenko
2014-08-01 11:18         ` [PATCHv4 3/3] " Andrei Emeltchenko
2014-08-01 11:26       ` [PATCHv5 1/3] tools: " Andrei Emeltchenko
2014-08-01 11:26         ` [PATCHv5 2/3] obexd: " Andrei Emeltchenko
2014-08-01 11:26         ` [PATCHv5 3/3] " Andrei Emeltchenko
2014-08-04  6:11         ` [PATCHv5 1/3] tools: " Johan Hedberg
2014-07-29 14:21   ` [PATCHv4 12/12] attrib: " Andrei Emeltchenko
2014-08-01 10:40     ` Johan Hedberg
2014-08-01  8:48   ` [PATCHv4 01/12] core: Remove unneeded assignment Andrei Emeltchenko

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=20140801112703.GC9036@aemeltch-MOBL1 \
    --to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox