2006-07-31 14:44:27

by Peter Wippich

[permalink] [raw]
Subject: [Bluez-devel] Refcounting problem in rfcomm


Hi all,

while trying to implement a server tty which can be used without a user
space daemon I came across a reference counting problem. Function
rfcomm_accept_connection()
calls __module_get(nsock->ops->owner) but there is no corresponding
module_put(). I think for user space sockets this won't be a problem.
However, if the owner of the socket is the rfcomm module itself the
reference count gets wrong.

A work around for this may be to decrement the reference count just before
releasing the socket used for listening.

Does anybody has some better idea ??

Thank you and best regards,

Peter


| Peter Wippich Voice: +49 30 46776411 |
| G&W Instruments GmbH fax: +49 30 46776419 |
| Gustav-Meyer-Allee 25, Geb. 12 Email: [email protected] |
| D-13355 Berlin / Germany |


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2006-07-31 16:33:01

by Peter Wippich

[permalink] [raw]
Subject: Re: [Bluez-devel] Refcounting problem in rfcomm



Hi Marcel,

> the RFCOMM module reference counting is not funny and you can mess it up
> on so many level. So be careful with it. I haven't looked at it, but
> from past experience I know that you can easily break things. So please
> give us some more details or code to show the problem.

You're right, the ref counting is realy something I don't want to change.
For now I've fixed it by a module_put() right after accept() returns with
a BT_CONNECTED state. I will do some more testing and code clean up and
then send in a patch for tty.c. Maybe I will send it in two steps because
I also don't like some general things in tty.c. E.g. rfcomm_dlc_lock /
unlock is used there several times but in parts of the codes which realy
don't deal with dlcs.
So adding a dev_lock is something which is independend of my other
changes.

Best regards,

Peter




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2006-07-31 18:13:57

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Refcounting problem in rfcomm

Hi Peter,

> while trying to implement a server tty which can be used without a user
> space daemon I came across a reference counting problem. Function
> rfcomm_accept_connection()
> calls __module_get(nsock->ops->owner) but there is no corresponding
> module_put(). I think for user space sockets this won't be a problem.
> However, if the owner of the socket is the rfcomm module itself the
> reference count gets wrong.
>
> A work around for this may be to decrement the reference count just before
> releasing the socket used for listening.

the RFCOMM module reference counting is not funny and you can mess it up
on so many level. So be careful with it. I haven't looked at it, but
from past experience I know that you can easily break things. So please
give us some more details or code to show the problem.

Regards

Marcel



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel