linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [Bluez-devel] rfcomm (utils)
@ 2006-06-07  0:35 Robert Wlaschin
  2006-06-07  7:13 ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Wlaschin @ 2006-06-07  0:35 UTC (permalink / raw)
  To: bluez-devel

In poking around in \bluez-utils-2.21\rfcomm\main.c, I noticed in
several functions (including print_dev_list) there seems to be a malloc
statement but no corresponding free.  Is this the recommended way to
handle the rfcomm_dev_list_req structures?

Thanks,
~Robert




_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] rfcomm (utils)
  2006-06-07  0:35 [Bluez-devel] rfcomm (utils) Robert Wlaschin
@ 2006-06-07  7:13 ` Marcel Holtmann
  2006-06-07 16:36   ` Robert Wlaschin
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2006-06-07  7:13 UTC (permalink / raw)
  To: BlueZ development

Hi Robert,

> In poking around in \bluez-utils-2.21\rfcomm\main.c, I noticed in
> several functions (including print_dev_list) there seems to be a malloc
> statement but no corresponding free.  Is this the recommended way to
> handle the rfcomm_dev_list_req structures?

this seems to be a bug, but I would prefer you actually check the latest
version from CVS instead of an old package and be more specific of the
cases you are talking about. Otherwise we can fix them.

Regards

Marcel




_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] rfcomm (utils)
@ 2006-06-07 15:12 Robert Wlaschin
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Wlaschin @ 2006-06-07 15:12 UTC (permalink / raw)
  To: bluez-devel, Steve Finney, Edwin Reich

Thanks for the quick response.

In reference, the current CVS available
http://bluez.cvs.sourceforge.net/bluez/ web site seems to have the same
issue.

Here's a suggested patch (using the 2.25 source)

--- bluez-utils-2.25/rfcomm/main.c.orig 2006-06-07 08:01:03.149584500
-0700
+++ bluez-utils-2.25/rfcomm/main.c.new  2006-06-07 08:02:25.915739200
-0700
@@ -132,11 +132,14 @@
 
        if (ioctl(ctl, RFCOMMGETDEVLIST, (void *) dl) < 0) {
                perror("Can't get device list");
+               free(dl);
                exit(1);
        }
 
        for (i = 0; i < dl->dev_num; i++)
                print_dev_info(di + i);
+
+       free(dl);
 }
 
 static int create_dev(int ctl, int dev, uint32_t flags, bdaddr_t
*bdaddr, int argc, char **argv)
@@ -237,12 +240,15 @@
 
        if (ioctl(ctl, RFCOMMGETDEVLIST, (void *) dl) < 0) {
                perror("Can't get device list");
+               free(dl);
                exit(1);
        }
 
        for (i = 0; i < dl->dev_num; i++)
                release_dev(ctl, (di + i)->id, 0);
 
+       free(dl);
+
        return 0;
 }


This should catch the missing deallocs.

Hope this helps.

Thanks,
Robert

Hi Robert,

> In poking around in \bluez-utils-2.21\rfcomm\main.c, I noticed in
> several functions (including print_dev_list) there seems to be a
malloc
> statement but no corresponding free.  Is this the recommended way to
> handle the rfcomm_dev_list_req structures?

this seems to be a bug, but I would prefer you actually check the latest
version from CVS instead of an old package and be more specific of the
cases you are talking about. Otherwise we can fix them.

Regards

Marcel




_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] rfcomm (utils)
  2006-06-07  7:13 ` Marcel Holtmann
@ 2006-06-07 16:36   ` Robert Wlaschin
  2006-06-07 20:12     ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Wlaschin @ 2006-06-07 16:36 UTC (permalink / raw)
  To: bluez-devel

Marcel Holtmann <marcel <at> holtmann.org> writes:

> 
> Hi Robert,
> 
> > In poking around in \bluez-utils-2.21\rfcomm\main.c, I noticed in
> > several functions (including print_dev_list) there seems to be a malloc
> > statement but no corresponding free.  Is this the recommended way to
> > handle the rfcomm_dev_list_req structures?
> 
> this seems to be a bug, but I would prefer you actually check the latest
> version from CVS instead of an old package and be more specific of the
> cases you are talking about. Otherwise we can fix them.
> 
> Regards
> 
> Marcel
> 

Marcel,

After reading some of the other posts I came to find out that diff -u is the
preferred format.  This is using utils/rfcomm/main.c v 1.18 from the CVS 
repository.

--- bluez-utils/rfcomm/main.c.orig 2006-06-07 09:20:23.180048500 -0700
+++ bluez-utils/rfcomm/main.c.new  2006-06-07 09:21:34.899257500 -0700
@@ -132,11 +132,14 @@
 
        if (ioctl(ctl, RFCOMMGETDEVLIST, (void *) dl) < 0) {
                perror("Can't get device list");
+               free(dl);
                exit(1);
        }
 
        for (i = 0; i < dl->dev_num; i++)
                print_dev_info(di + i);
+
+       free(dl);
 }
 
 static int create_dev(int ctl, int dev, uint32_t flags, bdaddr_t *bdaddr, int
argc, char **argv)
@@ -243,12 +246,15 @@
 
        if (ioctl(ctl, RFCOMMGETDEVLIST, (void *) dl) < 0) {
                perror("Can't get device list");
+               free(dl);
                exit(1);
        }
 
        for (i = 0; i < dl->dev_num; i++)
                release_dev(ctl, (di + i)->id, 0);
 
+       free(dl);
+
        return 0;
 }

Thanks,
Robert



_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] rfcomm (utils)
  2006-06-07 16:36   ` Robert Wlaschin
@ 2006-06-07 20:12     ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2006-06-07 20:12 UTC (permalink / raw)
  To: BlueZ development

Hi Robert,

> After reading some of the other posts I came to find out that diff -u is the
> preferred format.  This is using utils/rfcomm/main.c v 1.18 from the CVS 
> repository.

the context diffs are not really readable by any humans. However please
attach this patch, because your mail client converted all tabs into
whitespaces.

Regards

Marcel




_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-06-07 20:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-07  0:35 [Bluez-devel] rfcomm (utils) Robert Wlaschin
2006-06-07  7:13 ` Marcel Holtmann
2006-06-07 16:36   ` Robert Wlaschin
2006-06-07 20:12     ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2006-06-07 15:12 Robert Wlaschin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).