Driver Core fixes for 2.6.6-rc2
Subsystems (4)
PATCH 1/1 Driver Core fixes for 2.6.6-rc2
Hi,
Here are two driver core fixes for 2.6.6-rc2, along with a tipar.c driver fix.
Please pull from:
bk://kernel.bkbits.net/gregkh/linux/driver-2.6
thanks,
greg k-h
p.s. I'll send these as patches in response to this email to lkml for those who want to see them.
drivers/base/firmware_class.c | 2 +- drivers/char/tipar.c | 2 +- drivers/i2c/chips/eeprom.c | 1 + drivers/scsi/qla2xxx/qla_os.c | 2 ++ fs/sysfs/bin.c | 16 +++++++++++++--- fs/sysfs/symlink.c | 6 +++--- 6 files changed, 21 insertions(+), 8 deletions(-)
-----
<mebrown:michaels-house.net>:
o sysfs module unload race fix for bin_attributes
Linda Xie:
o symlink doesn't support kobj name > 20 charaters (KOBJ_NAME_LEN)
Romain Lievin:
o tipar char driver: wrong timeout value
PATCH 1/1 Driver Core fixes for 2.6.6-rc2
ChangeSet 1.1927, 2004/04/22 12:19:51-07:00, [email protected]
[PATCH] sysfs module unload race fix for bin_attributes
- Add module locking to sysfs bin_attribute files. Update all in-tree users to set module owner.
Compile tested. booted. stress tests pass:
while true; do modprobe mymod; rmmod mymod; done & while true; do hexdump -C /sys/path/to/sysfs/binary/file; done
drivers/base/firmware_class.c | 2 +- drivers/i2c/chips/eeprom.c | 1 + drivers/scsi/qla2xxx/qla_os.c | 2 ++ fs/sysfs/bin.c | 16 +++++++++++++--- 4 files changed, 17 insertions(+), 4 deletions(-)
drivers/base/firmware_class.c +1 -1
@@ -254,7 +254,7 @@return retval; }static struct bin_attribute firmware_attr_data_tmpl = { - .attr = {.name ="data" , .mode =0644 }, + .attr = {.name ="data" , .mode =0644 , .owner =THIS_MODULE }, .size =0 , .read = firmware_data_read, .write = firmware_data_write,
drivers/i2c/chips/eeprom.c +1 -0
@@ -155,6 +155,7 @@ .attr = { .name = "eeprom", .mode = S_IRUGO, + .owner = THIS_MODULE, }, .size = EEPROM_SIZE, .read = eeprom_read,
drivers/scsi/qla2xxx/qla_os.c +2 -0
@@ -402,6 +402,7 @@ .attr = { .name = "fw_dump", .mode = S_IRUSR | S_IWUSR, + .owner = THIS_MODULE, }, .size = 0, .read = qla2x00_sysfs_read_fw_dump,
@@ -415,6 +416,7 @@ .attr = { .name = "nvram", .mode = S_IRUSR | S_IWUSR, + .owner = THIS_MODULE, }, .size = sizeof(nvram_t), .read = qla2x00_sysfs_read_nvram,
fs/sysfs/bin.c +13 -3
@@ -101,19 +101,27 @@if (!kobj || !attr) goto Done; +/* Grab the module reference for this attribute if we have one */ + error = -ENODEV ; +if (!try_module_get (attr->attr.owner)) + goto Done; + error = -EACCES ;if ((file->f_mode &FMODE_WRITE ) && !attr->write) - goto Done; + goto Error;if ((file->f_mode &FMODE_READ ) && !attr->read) - goto Done; + goto Error; error = -ENOMEM ; file->private_data =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!file->private_data) - goto Done; + goto Error; error =0 ; + goto Done; + Error: +module_put (attr->attr.owner); Done:if (error && kobj)kobject_put (kobj);
@@ -123,10 +131,12 @@static int release (struct inode * inode,struct file * file) {struct kobject * kobj = file->f_dentry->d_parent->d_fsdata; +struct bin_attribute * attr = file->f_dentry->d_fsdata;u8 * buffer = file->private_data;if (kobj)kobject_put (kobj); +module_put (attr->attr.owner);kfree (buffer);return 0 ; }
ChangeSet 1.1928, 2004/04/22 14:36:55-07:00, [email protected]
[PATCH] tipar char driver: wrong timeout value
this patch (2.4 & 2.6) fixes a bug about the timeout value. The formula used to calculate jiffies from timeout is wrong.
The new formula is ok and takes care of integer computation/rounding. There is the same bug in the tiglusb.c module which will be fixed by another patch.
drivers/char/tipar.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/char/tipar.c +1 -1
@@ -121,7 +121,7 @@/* ----- global defines ----------------------------------------------- */ -#define START (x) { x=jiffies+HZ/(timeout/10); } +#define START (x) { x = jiffies + (HZ * timeout) / 10; }#define WAIT (x) { \ if (time_before((x), jiffies)) return -1; \ if (need_resched()) schedule(); }
ChangeSet 1.1929, 2004/04/22 15:11:12-07:00, [email protected]
[PATCH] symlink doesn't support kobj name > 20 charaters (KOBJ_NAME_LEN)
Since symlink.c uses "name" field of a kobj when it calculates the length, it gets a wrong value if the kobj's name has more than 20 charathers. A correct way to do that is to call kobject_name(kobj) instead of using kobj->name directly.
fs/sysfs/symlink.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
fs/sysfs/symlink.c +3 -3
@@ -42,7 +42,7 @@struct kobject * p = kobj;int length =1 ;do { - length +=strlen (p->name) +1 ; + length +=strlen (kobject_name (p)) +1 ; p = p->parent; }while (p);return length;
@@ -54,11 +54,11 @@ --length;for (p = kobj; p; p = p->parent) { -int cur =strlen (p->name); +int cur =strlen (kobject_name (p));/* back up enough to print this bus id with '/' */ length -= cur; -strncpy (buffer + length,p->name,cur); +strncpy (buffer + length,kobject_name (p),cur); *(buffer + --length) ='/' ; } }