This patch correct the flaw identified by Pete Zaitcev.

Plus I now fully understand the sysfs oops.
It is not a problem with sysfs, so GregKH rightly ignored me.

A pointer to control_interface->dev is saved in the tty class device
object created by tty_register_device(). This reference is used to
create/destroy sysfs symlinks between the tty class device object and the
control_interface->dev. On disconnect control_interface->dev is released.
tty_unregister_device() is called later when the last tty file desc
is closed. tty_unregister_device() then passes the stale pointer
to sysfs_remove_link() causing the oops if the slab debug is turned on.

So the below patch seems the cleanest way of fixing this.


Patch Description:

Clear acm->tty on last close because the tty layer
releases the tty object at that point.

Use a NULL device with tty_register_device() to prevent
tty layer from creating sysfs entries referencing the usb device.
This prevents oops in sysfs_hash_and_remove when tty_unregister_device
is called after usb device is disconnected during use. By the time
tty_unregister_device is called, the usb device has already been released.

Signed-off-by: Paul Fulghum <[EMAIL PROTECTED]>


--- linux-2.6.16-rc5/drivers/usb/class/cdc-acm.c        2006-02-27 
14:40:21.000000000 -0600
+++ b/drivers/usb/class/cdc-acm.c       2006-03-13 12:28:19.000000000 -0600
@@ -515,6 +515,7 @@ static void acm_tty_close(struct tty_str
                        usb_kill_urb(acm->writeurb);
                        for (i = 0; i < ACM_NRU; i++)
                                usb_kill_urb(acm->ru[i].urb);
+                       acm->tty = NULL;
                } else
                        acm_tty_unregister(acm);
        }
@@ -980,7 +981,7 @@ skip_normal_probe:
        usb_driver_claim_interface(&acm_driver, data_interface, acm);
 
        usb_get_intf(control_interface);
-       tty_register_device(acm_tty_driver, minor, &control_interface->dev);
+       tty_register_device(acm_tty_driver, minor, NULL);
 
        acm_table[minor] = acm;
        usb_set_intfdata (intf, acm);




-------------------------------------------------------
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