public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] SDP memory leak?
@ 2004-08-27 12:32 Stefan Mischke
  2004-08-27 12:49 ` Marcel Holtmann
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Mischke @ 2004-08-27 12:32 UTC (permalink / raw)
  To: BlueZ Mailing List; +Cc: Stefan Mischke (E-Mail)

Hello,

I have a question about "bnep_sdp_search()" from 
"bluez-pan-1.1/pand/sdp.c" (see below for the code).
If I see it correctly, the memory for "sdp_list_t *srch, *rsp" is 
allocated by "sdp_service_search_req()".
But "bnep_sdp_search()" accesses the pointer "rsp" after it has done 
"sdp_close()".
So my question is: 'Who will ever free the memory allocated at "rsp" and 
when?'

I quite new to this, so I probably have missed something. So sorry if 
this is a stupid one :-).

Kind regards
Stefan

<CODE>
int bnep_sdp_search(bdaddr_t *src, bdaddr_t *dst, uint16_t service)
{
    sdp_list_t *srch, *rsp = NULL;
    sdp_session_t *s;
    uuid_t svclass;
    int err;

    switch (service) {
    case BNEP_SVC_PANU:
        sdp_uuid16_create(&svclass, PANU_SVCLASS_ID);
        break;
    case BNEP_SVC_NAP:
        sdp_uuid16_create(&svclass, NAP_SVCLASS_ID);
        break;
    case BNEP_SVC_GN:
        sdp_uuid16_create(&svclass, GN_SVCLASS_ID);
        break;
    }
       
    srch = sdp_list_append(NULL, &svclass);

    s = sdp_connect(src, dst, 0);
    if (!s) {
        syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
                strerror(errno), errno);
        return 0;
    }

    err = sdp_service_search_req(s, srch, 1, &rsp);
    sdp_close(s);

    /* Assume that search is successeful
     * if at least one record is found */
    if (!err && sdp_list_len(rsp))
        return 1;

    return 0;
} </CODE>



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

* Re: [Bluez-devel] SDP memory leak?
  2004-08-27 12:32 [Bluez-devel] SDP memory leak? Stefan Mischke
@ 2004-08-27 12:49 ` Marcel Holtmann
  2004-08-27 13:24   ` Stefan Mischke
  2004-08-27 13:31   ` Stephen Crane
  0 siblings, 2 replies; 8+ messages in thread
From: Marcel Holtmann @ 2004-08-27 12:49 UTC (permalink / raw)
  To: Stefan Mischke; +Cc: BlueZ Mailing List, Stefan Mischke (E-Mail)

Hi Stefan,

> I have a question about "bnep_sdp_search()" from 
> "bluez-pan-1.1/pand/sdp.c" (see below for the code).
> If I see it correctly, the memory for "sdp_list_t *srch, *rsp" is 
> allocated by "sdp_service_search_req()".
> But "bnep_sdp_search()" accesses the pointer "rsp" after it has done 
> "sdp_close()".
> So my question is: 'Who will ever free the memory allocated at "rsp" and 
> when?'
> 
> I quite new to this, so I probably have missed something. So sorry if 
> this is a stupid one :-).

no, I think you are right. I expect more memory leaks in the SDP code.
We need some people to check this and send me patches.

Regards

Marcel




-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

* Re: [Bluez-devel] SDP memory leak?
  2004-08-27 12:49 ` Marcel Holtmann
@ 2004-08-27 13:24   ` Stefan Mischke
  2004-08-27 13:28     ` Marcel Holtmann
  2004-08-27 13:31   ` Stephen Crane
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Mischke @ 2004-08-27 13:24 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: BlueZ Mailing List, Stefan Mischke (E-Mail)

Hi!

Marcel Holtmann schrieb:

>no, I think you are right. I expect more memory leaks in the SDP code.
>We need some people to check this and send me patches.
>  
>
Well then, I just figured out (in my own TestApp based on 
"bnep_sdp_search()") that it simply doesn't work like this. I propose to 
do "sdp_close()" as the last sdp_* call (as in the code below). Same 
with dund. So there might be no memory leak but an illegal pointer 
access. One has to correct "pand/sdp.c" and "dund/sdp.c".

Regards
Stefan

<CODE>

int bnep_sdp_search(bdaddr_t *src, bdaddr_t *dst, uint16_t service)
{
    sdp_list_t *srch, *rsp = NULL;
    sdp_session_t *s;
    uuid_t svclass;
    int err, res;

    switch (service) {
    case BNEP_SVC_PANU:
        sdp_uuid16_create(&svclass, PANU_SVCLASS_ID);
        break;
    case BNEP_SVC_NAP:
        sdp_uuid16_create(&svclass, NAP_SVCLASS_ID);
        break;
    case BNEP_SVC_GN:
        sdp_uuid16_create(&svclass, GN_SVCLASS_ID);
        break;
    }
       
    srch = sdp_list_append(NULL, &svclass);

    s = sdp_connect(src, dst, 0);
    if (!s) {
        syslog(LOG_ERR, "Failed to connect to the SDP server. %s(%d)",
                strerror(errno), errno);
        return 0;
    }

    err = sdp_service_search_req(s, srch, 1, &rsp);
    res = sdp_list_len(rsp);
    sdp_close(s);

    /* Assume that search is successeful
     * if at least one record is found */
    if (!err && res)
        return 1;

    return 0;
}

</CODE>

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

* Re: [Bluez-devel] SDP memory leak?
  2004-08-27 13:24   ` Stefan Mischke
@ 2004-08-27 13:28     ` Marcel Holtmann
  0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2004-08-27 13:28 UTC (permalink / raw)
  To: Stefan Mischke; +Cc: BlueZ Mailing List, Stefan Mischke (E-Mail)

Hi Stefan,

> Well then, I just figured out (in my own TestApp based on 
> "bnep_sdp_search()") that it simply doesn't work like this. I propose to 
> do "sdp_close()" as the last sdp_* call (as in the code below). Same 
> with dund. So there might be no memory leak but an illegal pointer 
> access. One has to correct "pand/sdp.c" and "dund/sdp.c".

I am very busy with some other problems and I am not the expert when it
comes to the SDP code. Write a patch that I can apply and show me that
it is the right way to do it. Be careful with the other return pathes in
that functions.

Regards

Marcel




-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

* Re: [Bluez-devel] SDP memory leak?
  2004-08-27 12:49 ` Marcel Holtmann
  2004-08-27 13:24   ` Stefan Mischke
@ 2004-08-27 13:31   ` Stephen Crane
  2004-08-27 13:34     ` Marcel Holtmann
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Crane @ 2004-08-27 13:31 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Stefan Mischke, BlueZ Mailing List, Stefan Mischke (E-Mail)

The sdp library is free (I think) of memory leaks, thanks to the wonders
of valgrind: http://valgrind.kde.org.

On Fri, 2004-08-27 at 13:49, Marcel Holtmann wrote:
> Hi Stefan,
> 
> > I have a question about "bnep_sdp_search()" from 
> > "bluez-pan-1.1/pand/sdp.c" (see below for the code).
> > If I see it correctly, the memory for "sdp_list_t *srch, *rsp" is 
> > allocated by "sdp_service_search_req()".
> > But "bnep_sdp_search()" accesses the pointer "rsp" after it has done 
> > "sdp_close()".
> > So my question is: 'Who will ever free the memory allocated at "rsp" and 
> > when?'
> > 
> > I quite new to this, so I probably have missed something. So sorry if 
> > this is a stupid one :-).
> 
> no, I think you are right. I expect more memory leaks in the SDP code.
> We need some people to check this and send me patches.
> 
> Regards
> 
> Marcel
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
-- 
Stephen Crane, Rococo Software Ltd. http://www.rococosoft.com
steve.crane@rococosoft.com +353-1-6601315 (ext 209)

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

* Re: [Bluez-devel] SDP memory leak?
  2004-08-27 13:31   ` Stephen Crane
@ 2004-08-27 13:34     ` Marcel Holtmann
  2004-08-27 14:40       ` Stephen Crane
  0 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2004-08-27 13:34 UTC (permalink / raw)
  To: Stephen Crane; +Cc: Stefan Mischke, BlueZ Mailing List, Stefan Mischke (E-Mail)

Hi Steve,

> The sdp library is free (I think) of memory leaks, thanks to the wonders
> of valgrind: http://valgrind.kde.org.

would you also take care of the tools in bluez-utils that uses the SDP
library?

Regards

Marcel




-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

* Re: [Bluez-devel] SDP memory leak?
  2004-08-27 13:34     ` Marcel Holtmann
@ 2004-08-27 14:40       ` Stephen Crane
  2004-08-27 17:26         ` Marcel Holtmann
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Crane @ 2004-08-27 14:40 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Stefan Mischke, BlueZ Mailing List, Stefan Mischke (E-Mail)

Hi Marcel, Stefan,

On Fri, 2004-08-27 at 14:34, Marcel Holtmann wrote:
> Hi Steve,
> 
> > The sdp library is free (I think) of memory leaks, thanks to the wonders
> > of valgrind: http://valgrind.kde.org.
> 
> would you also take care of the tools in bluez-utils that uses the SDP
> library?

I have just committed changes to pand's service registration. The CVS
diff should show what is required to fix this in the other applications.
(Note: sdptool also cleans up properly in its "add" subcommands.)

Unfortunately I haven't time to do the others at the moment but this
should be a start for others. (Send in the patches!)

Regards,
Steve
-- 
Stephen Crane, Rococo Software Ltd. http://www.rococosoft.com
steve.crane@rococosoft.com +353-1-6601315 (ext 209)

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

* Re: [Bluez-devel] SDP memory leak?
  2004-08-27 14:40       ` Stephen Crane
@ 2004-08-27 17:26         ` Marcel Holtmann
  0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2004-08-27 17:26 UTC (permalink / raw)
  To: Stephen Crane; +Cc: Stefan Mischke, BlueZ Mailing List, Stefan Mischke (E-Mail)

Hi Steve,

> I have just committed changes to pand's service registration. The CVS
> diff should show what is required to fix this in the other applications.
> (Note: sdptool also cleans up properly in its "add" subcommands.)

many thanks.

> Unfortunately I haven't time to do the others at the moment but this
> should be a start for others. (Send in the patches!)

Stefan and others, now it is your turn to get involved ;)

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

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

end of thread, other threads:[~2004-08-27 17:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-27 12:32 [Bluez-devel] SDP memory leak? Stefan Mischke
2004-08-27 12:49 ` Marcel Holtmann
2004-08-27 13:24   ` Stefan Mischke
2004-08-27 13:28     ` Marcel Holtmann
2004-08-27 13:31   ` Stephen Crane
2004-08-27 13:34     ` Marcel Holtmann
2004-08-27 14:40       ` Stephen Crane
2004-08-27 17:26         ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox