On Tue, 2006-03-14 at 09:05 -0800, Greg KH wrote:
> Ah, wait, that's the issue right there.  You need to increment the
> reference count of the object on open and then decrement it on close.
> That way the last close will drop the last reference, and you do that
> _after_ the tty cleanup.

acm_probe() gets a reference to acm->control->dev
just before calling tty_register_device(), and it holds that
reference until just after calling tty_unregister_device().

sysfs also takes a reference to acm->control->dev
as the target of a symlink

So there should be at least two references pinning
acm->control->dev on entry to tty_unregister_device.

The printk patch I asked Bob to try should tell us
the actual reference counts. Maybe the counts get
out of wack someplace else.

Adding extra reference on tty open may work,
but may just cover an existing reference count problem.

The two calls resulting from tty_unregister_device():

 sysfs_remove_link(&class_dev->kobj, "device");
 sysfs_remove_link(&class_dev->dev->kobj, class_name);

The first call removes the link where acm->control->dev
is the target, which drops one reference. The second
call directly accesses acm->control->dev. So if the
reference count gets off by even one, the second call
could oops.

That's my best understanding of it at this point,
but I've been wrong on my last couple of assertions.

It may be worth waiting for Bob to report the actual
ref counts before adding another ref on tty open.

-- 
Paul Fulghum
Microgate Systems, Ltd



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to