From: Tejun Heo <htejun@gmail.com>
To: Chris Rankin <rankincj@yahoo.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
linux-usb-devel@lists.sourceforge.net,
linux-kernel <linux-kernel@vger.kernel.org>,
Greg K-H <greg@kroah.com>
Subject: Re: [linux-usb-devel] Bug creating USB endpoints in 2.6.20.x (kernel bug 8198)
Date: Wed, 09 May 2007 15:30:41 +0200 [thread overview]
Message-ID: <4641CD01.6010309@gmail.com> (raw)
In-Reply-To: <602729.80444.qm@web52910.mail.re2.yahoo.com>
[-- Attachment #1: Type: text/plain, Size: 834 bytes --]
Chris Rankin wrote:
> --- Tejun Heo <htejun@gmail.com> wrote:
>> So, we can fix the problem Chris is seeing by breaking module unload (by
>> allowing it to unload too early). It doesn't sound too hot but module
>> unloading race is much less likely than sysfs node deletion/open race.
>
> Yikes! Just temporary breakage, I hope :-)!! The only modules I unload on a regular basis these
> days are things like "microcode", which the init scripts take care of as part of the boot-up
> process.
Okay, here's a half-assed fix. With this patch applied, if you try to
unload a module while you're opening it's dev attribute, kernel will
oops later when the file is accessed or closed later but it should fix
the bug winecfg triggers. I really dunno how to fix this the right way
in the stable kernel. Better ideas? Anyone?
--
tejun
[-- Attachment #2: sysfs-race-fix.patch --]
[-- Type: text/x-patch, Size: 2413 bytes --]
---
drivers/base/core.c | 33 ++++++++-------------------------
include/linux/device.h | 1 -
2 files changed, 8 insertions(+), 26 deletions(-)
Index: tree0/drivers/base/core.c
===================================================================
--- tree0.orig/drivers/base/core.c
+++ tree0/drivers/base/core.c
@@ -287,6 +287,8 @@ static ssize_t show_dev(struct device *d
return print_dev_t(buf, dev->devt);
}
+static struct device_attribute devt_attr = __ATTR(dev, S_IRUGO, show_dev, NULL );
+
/*
* devices_subsys - structure to be registered with kobject core.
*/
@@ -490,24 +492,9 @@ int device_add(struct device *dev)
goto attrError;
if (MAJOR(dev->devt)) {
- struct device_attribute *attr;
- attr = kzalloc(sizeof(*attr), GFP_KERNEL);
- if (!attr) {
- error = -ENOMEM;
- goto ueventattrError;
- }
- attr->attr.name = "dev";
- attr->attr.mode = S_IRUGO;
- if (dev->driver)
- attr->attr.owner = dev->driver->owner;
- attr->show = show_dev;
- error = device_create_file(dev, attr);
- if (error) {
- kfree(attr);
+ error = device_create_file(dev, &devt_attr);
+ if (error)
goto ueventattrError;
- }
-
- dev->devt_attr = attr;
}
if (dev->class) {
@@ -568,10 +555,8 @@ int device_add(struct device *dev)
GroupError:
device_remove_attrs(dev);
AttrsError:
- if (dev->devt_attr) {
- device_remove_file(dev, dev->devt_attr);
- kfree(dev->devt_attr);
- }
+ if (MAJOR(dev->devt))
+ device_remove_file(dev, &devt_attr);
ueventattrError:
device_remove_file(dev, &dev->uevent_attr);
attrError:
@@ -650,10 +635,8 @@ void device_del(struct device * dev)
if (parent)
klist_del(&dev->knode_parent);
- if (dev->devt_attr) {
- device_remove_file(dev, dev->devt_attr);
- kfree(dev->devt_attr);
- }
+ if (MAJOR(dev->devt))
+ device_remove_file(dev, &devt_attr);
if (dev->class) {
sysfs_remove_link(&dev->kobj, "subsystem");
/* If this is not a "fake" compatible device, remove the
Index: tree0/include/linux/device.h
===================================================================
--- tree0.orig/include/linux/device.h
+++ tree0/include/linux/device.h
@@ -357,7 +357,6 @@ struct device {
char bus_id[BUS_ID_SIZE]; /* position on parent bus */
unsigned is_registered:1;
struct device_attribute uevent_attr;
- struct device_attribute *devt_attr;
struct semaphore sem; /* semaphore to synchronize calls to
* its driver.
next prev parent reply other threads:[~2007-05-09 13:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <963898.10047.qm@web52906.mail.re2.yahoo.com>
2007-05-09 9:40 ` [linux-usb-devel] Bug creating USB endpoints in 2.6.20.x (kernel bug 8198) Tejun Heo
2007-05-09 12:24 ` Chris Rankin
2007-05-09 13:30 ` Tejun Heo [this message]
2007-05-09 13:56 ` Chris Rankin
2007-05-09 14:11 ` Tejun Heo
2007-05-09 14:35 ` Dmitry Torokhov
2007-05-09 14:58 ` Tejun Heo
2007-05-09 21:09 ` Chris Rankin
2007-05-09 14:57 ` Greg KH
2007-05-09 15:01 ` Tejun Heo
2007-05-09 15:40 ` Greg KH
2007-05-10 14:45 ` [PATCH] driver-core: don't free devt_attr till the device is released Tejun Heo
2007-05-10 15:05 ` Greg KH
2007-05-10 15:13 ` Tejun Heo
2007-05-10 15:17 ` Greg KH
2007-05-10 15:33 ` Kay Sievers
2007-05-10 15:41 ` Tejun Heo
2007-05-10 15:52 ` Alan Stern
2007-05-10 16:18 ` Tejun Heo
2007-05-10 14:25 ` [PATCH 2.6.21-mm2] driver-core: make devt_attr and uevent_attr static Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4641CD01.6010309@gmail.com \
--to=htejun@gmail.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=rankincj@yahoo.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox