Re: Bug creating USB endpoints in 2.6.20.x (kernel bug 8198)
Tejun Heo <[email protected]>
| Newsgroups | gmane.linux.usb.devel,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
Dmitry Torokhov wrote: >> As written above, I think it's better to risk module unload / sysfs race >> than keeping the current sysfs deletion / open race. What do you guys >> think? >> > > How about embedding struct attribute fro devt into struct > [class_]device for now? It is not too big and device is still going to > be pinned into memory while there are sysfs users... I don't like > fattening of device structures but leaks and/or oopses are worse in my > book. Right, your book is apparently much better than mine. Actually, we can just free devt_attr in device_release(). Looking at the code, class device is already doing it that way, so here's the full-assed fix. Chris, can you please test the attached patch? Thanks. -- tejun ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
fix-devt_attr-release
(text/plain, 857 B)
---
drivers/base/core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: tree0/drivers/base/core.c
===================================================================
--- tree0.orig/drivers/base/core.c
+++ tree0/drivers/base/core.c
@@ -93,6 +93,9 @@ static void device_release(struct kobjec
{
struct device * dev = to_dev(kobj);
+ kfree(dev->devt_attr);
+ dev->devt_attr = NULL;
+
if (dev->release)
dev->release(dev);
else if (dev->class && dev->class->dev_release)
@@ -650,10 +653,8 @@ void device_del(struct device * dev)
if (parent)
klist_del(&dev->knode_parent);
- if (dev->devt_attr) {
+ if (dev->devt_attr)
device_remove_file(dev, dev->devt_attr);
- kfree(dev->devt_attr);
- }
if (dev->class) {
sysfs_remove_link(&dev->kobj, "subsystem");
/* If this is not a "fake" compatible device, remove the