Driver Core fixes for 2.6.19-rc2
Subsystems (2)
PATCH 1/1 Driver Core fixes for 2.6.19-rc2
Here are some driver core and sysfs fixes for 2.6.19-rc2.
All of these patches have been in the -mm tree for a quite a while.
Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
or if master.kernel.org hasn't synced up yet:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6.git/
Patches will be sent as a follow-on to this message to lkml for people to see.
thanks,
greg k-h
Documentation/HOWTO | 20 +++++ Documentation/feature-removal-schedule.txt | 2 - drivers/base/bus.c | 108 +++++++++++++++++----------- drivers/base/class.c | 5 + drivers/base/core.c | 26 +++++-- drivers/base/dd.c | 4 + drivers/base/dmapool.c | 13 +++ drivers/base/topology.c | 3 - fs/sysfs/file.c | 7 -- 9 files changed, 123 insertions(+), 65 deletions(-)
---------------
Akinobu Mita:
driver core: kmalloc() failure check in driver_probe_device
Alan Stern:
Driver core: Don't ignore error returns from probing
Cornelia Huck:
driver core fixes: sysfs_create_link() retval check in class.c driver core fixes: bus_add_attrs() retval check
driver core fixes: bus_add_device() cleanup on error driver core fixes: device_add() cleanup on error driver core fixes: device_create_file() retval check in dmapool.c driver core fixes: sysfs_create_group() retval in topology.c
Diego Calleja:
HOWTO: bug report addition
Dominik Brodowski:
Documentation: feature-removal-schedule typo
Duncan Sands:
Driver core: plug device probe memory leak
Hidetoshi Seto:
sysfs: remove duplicated dput in sysfs_update_file
sysfs: update obsolete comment in sysfs_update_file
Jeff Garzik:
Driver core: bus: remove indentation level
Jesper Juhl:
Driver core: Don't leak 'old_class_name' in drivers/base/core.c::device_rename()
Matthew Wilcox:
Fix dev_printk() is now GPL-only
PATCH 2/16 Driver core: plug device probe memory leak
In reply to Greg KHFrom: Duncan Sands <[email protected]>
Make sure data is freed if the kthread fails to start.
--- drivers/base/dd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/base/dd.c +1 -1
@@ -178,7 +178,7 @@ int driver_probe_device(struct device_dr probe_task =kthread_run (really_probe, data,"probe-%s" , dev->bus_id);if (IS_ERR (probe_task)) - ret =PTR_ERR (probe_task); + ret =really_probe (data); }else ret =really_probe (data);
Signature · 1 line
1.4.2.4
PATCH 10/16 driver core fixes: device_add() cleanup on error
In reply to Greg KHFrom: Cornelia Huck <[email protected]>
Check for return code of device_create_file() and correct cleanup in the error case in device_add().
--- drivers/base/core.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/base/core.c +7 -3
@@ -433,14 +433,16 @@ int device_add(struct device *dev)if (dev->driver) dev->uevent_attr.attr.owner = dev->driver->owner; dev->uevent_attr.store = store_uevent; -device_create_file (dev, &dev->uevent_attr); + error =device_create_file (dev, &dev->uevent_attr); +if (error) + goto attrError;if (MAJOR (dev->devt)) {struct device_attribute *attr; attr =kzalloc (sizeof (*attr),GFP_KERNEL );if (!attr) { error = -ENOMEM ; - goto PMError; + goto ueventattrError; } attr->attr.name ="dev" ; attr->attr.mode =S_IRUGO ;
@@ -450,7 +452,7 @@ int device_add(struct device *dev) error =device_create_file (dev, attr);if (error) {kfree (attr); - goto attrError; + goto ueventattrError; } dev->devt_attr = attr;
@@ -507,6 +509,8 @@ int device_add(struct device *dev)device_remove_file (dev, dev->devt_attr);kfree (dev->devt_attr); } + ueventattrError: +device_remove_file (dev, &dev->uevent_attr); attrError:kobject_uevent (&dev->kobj,KOBJ_REMOVE );kobject_del (&dev->kobj);
Signature · 1 line
1.4.2.4
PATCH 5/16 sysfs: remove duplicated dput in sysfs_update_file
In reply to Greg KHFrom: Hidetoshi Seto <[email protected]>
Following function can drops d_count twice against one reference by lookup_one_len.
<SOURCE>
/**
* sysfs_update_file - update the modified timestamp on an object attribute.
* @kobj: object we're acting for.
* @attr: attribute descriptor.
*/
int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
{
struct dentry * dir = kobj->dentry;
struct dentry * victim;
int res = -ENOENT;
mutex_lock(&dir->d_inode->i_mutex);
victim = lookup_one_len(attr->name, dir, strlen(attr->name));
if (!IS_ERR(victim)) {
/* make sure dentry is really there */
if (victim->d_inode &&
(victim->d_parent->d_inode == dir->d_inode)) {
victim->d_inode->i_mtime = CURRENT_TIME;
fsnotify_modify(victim);
/**
* Drop reference from initial sysfs_get_dentry().
*/
dput(victim);
res = 0;
} else
d_drop(victim);
/**
* Drop the reference acquired from sysfs_get_dentry() above.
*/
dput(victim);
}
mutex_unlock(&dir->d_inode->i_mutex);
return res;
}</SOURCE>
PCI-hotplug (drivers/pci/hotplug/pci_hotplug_core.c) is only user of this function. I confirmed that dentry of /sys/bus/pci/slots/XXX/* have negative d_count value.
This patch removes unnecessary dput().
--- fs/sysfs/file.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
fs/sysfs/file.c +0 -5
@@ -483,11 +483,6 @@ int sysfs_update_file(struct kobject * k (victim->d_parent->d_inode == dir->d_inode)) { victim->d_inode->i_mtime =CURRENT_TIME ;fsnotify_modify (victim); - -/** -* Drop reference from initial sysfs_get_dentry(). -*/ -dput (victim); res =0 ; } elsed_drop (victim );
Signature · 1 line
1.4.2.4
PATCH 6/16 sysfs: update obsolete comment in sysfs_update_file
From: Hidetoshi Seto <[email protected]>
And the obsolete comment should be updated (or totally removed).
--- fs/sysfs/file.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/sysfs/file.c +1 -1
@@ -488,7 +488,7 @@ int sysfs_update_file(struct kobject * kd_drop (victim);/** -* Drop the reference acquired from sysfs_get_dentry() above. +* Drop the reference acquired from lookup_one_len() above. */ dput (victim); }
Signature · 1 line
1.4.2.4
PATCH 7/16 driver core fixes: sysfs_create_link() retval check in class.c
From: Cornelia Huck <[email protected]>
Check for return value of sysfs_create_link() in class_device_add().
--- drivers/base/class.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/base/class.c +4 -1
@@ -562,7 +562,10 @@ int class_device_add(struct class_device goto out2;/* add the needed attributes to this device */ -sysfs_create_link (&class_dev->kobj, &parent_class->subsys.kset.kobj,"subsystem" ); + error =sysfs_create_link (&class_dev->kobj, + &parent_class->subsys.kset.kobj,"subsystem" ); +if (error) + goto out3; class_dev->uevent_attr.attr.name ="uevent" ; class_dev->uevent_attr.attr.mode =S_IWUSR ; class_dev->uevent_attr.attr.owner = parent_class->owner;
Signature · 1 line
1.4.2.4
PATCH 15/16 Driver core: bus: remove indentation level
In reply to Greg KHFrom: Jeff Garzik <[email protected]>
Before potentially fixing up these functions, this cosmetic change reduces the indentation level to make the code easier to read and maintain.
No functional changes at all.
--- drivers/base/bus.c | 77 +++++++++++++++++++++++++++------------------------- 1 files changed, 40 insertions(+), 37 deletions(-)
drivers/base/bus.c +40 -37
@@ -518,34 +518,36 @@ int bus_add_driver(struct device_driverstruct bus_type * bus =get_bus (drv->bus);int error =0 ; -if (bus) { -pr_debug ("bus %s: add driver %s\n" , bus->name, drv->name); - error =kobject_set_name (&drv->kobj,"%s" , drv->name); -if (error) - goto out_put_bus; - drv->kobj.kset = &bus->drivers; -if ((error =kobject_register (&drv->kobj))) - goto out_put_bus; - - error =driver_attach (drv); -if (error) - goto out_unregister; -klist_add_tail (&drv->knode_bus, &bus->klist_drivers); -module_add_driver (drv->owner, drv); - - error =driver_add_attrs (bus, drv); -if (error) { -/* How the hell do we get out of this pickle? Give up */ -printk (KERN_ERR "%s: driver_add_attrs(%s) failed\n" , - __FUNCTION__, drv->name); - } - error =add_bind_files (drv); -if (error) { -/* Ditto */ -printk (KERN_ERR "%s: add_bind_files(%s) failed\n" , - __FUNCTION__, drv->name); - } +if (!bus) +return 0 ; + +pr_debug ("bus %s: add driver %s\n" , bus->name, drv->name); + error =kobject_set_name (&drv->kobj,"%s" , drv->name); +if (error) + goto out_put_bus; + drv->kobj.kset = &bus->drivers; +if ((error =kobject_register (&drv->kobj))) + goto out_put_bus; + + error =driver_attach (drv); +if (error) + goto out_unregister; +klist_add_tail (&drv->knode_bus, &bus->klist_drivers); +module_add_driver (drv->owner, drv); + + error =driver_add_attrs (bus, drv); +if (error) { +/* How the hell do we get out of this pickle? Give up */ +printk (KERN_ERR "%s: driver_add_attrs(%s) failed\n" , + __FUNCTION__, drv->name); + } + error =add_bind_files (drv); +if (error) { +/* Ditto */ +printk (KERN_ERR "%s: add_bind_files(%s) failed\n" , + __FUNCTION__, drv->name); } +return error; out_unregister:kobject_unregister (&drv->kobj);
@@ -565,16 +567,17 @@ out_put_bus:void bus_remove_driver (struct device_driver * drv) { -if (drv->bus) { -remove_bind_files (drv); -driver_remove_attrs (drv->bus, drv); -klist_remove (&drv->knode_bus); -pr_debug ("bus %s: remove driver %s\n" , drv->bus->name, drv->name); -driver_detach (drv); -module_remove_driver (drv); -kobject_unregister (&drv->kobj); -put_bus (drv->bus); - } +if (!drv->bus) +return ; + +remove_bind_files (drv); +driver_remove_attrs (drv->bus, drv); +klist_remove (&drv->knode_bus); +pr_debug ("bus %s: remove driver %s\n" , drv->bus->name, drv->name); +driver_detach (drv); +module_remove_driver (drv); +kobject_unregister (&drv->kobj); +put_bus (drv->bus); }
Signature · 1 line
1.4.2.4
PATCH 3/16 Fix dev_printk() is now GPL-only
In reply to Greg KHFrom: Matthew Wilcox <[email protected]>
Make dev_printk usable from non-GPL modules again
dev_printk now calls dev_driver_string. We want even proprietary modules to be calling dev_printk, so the export of dev_driver_string needs to be non-GPL-only.
--- drivers/base/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/base/core.c +1 -1
@@ -44,7 +44,7 @@ const char *dev_driver_string(struct devreturn dev->driver ? dev->driver->name : (dev->bus ? dev->bus->name :"" ); } -EXPORT_SYMBOL_GPL (dev_driver_string); +EXPORT_SYMBOL (dev_driver_string);#define to_dev (obj) container_of(obj, struct device, kobj)#define to_dev_attr (_attr) container_of(_attr, struct device_attribute, attr)
Signature · 1 line
1.4.2.4
PATCH 16/16 driver core: kmalloc() failure check in driver_probe_device
In reply to Greg KHFrom: Akinobu Mita <[email protected]>
driver_probe_device() is missing kmalloc() failure check.
--- drivers/base/dd.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/base/dd.c +2 -0
@@ -171,6 +171,8 @@ int driver_probe_device(struct device_dr drv->bus->name, dev->bus_id, drv->name); data =kmalloc (sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; data->drv = drv; data->dev = dev;
Signature · 1 line
1.4.2.4
PATCH 8/16 driver core fixes: bus_add_attrs() retval check
In reply to Greg KHFrom: Cornelia Huck <[email protected]>
Check return value of bus_add_attrs() in bus_register().
--- drivers/base/bus.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/base/bus.c +5 -1
@@ -732,11 +732,15 @@ int bus_register(struct bus_type * bus)klist_init (&bus->klist_devices, klist_devices_get, klist_devices_put);klist_init (&bus->klist_drivers,NULL ,NULL ); -bus_add_attrs (bus); + retval =bus_add_attrs (bus); +if (retval) + goto bus_attrs_fail;pr_debug ("bus type '%s' registered\n" , bus->name);return 0 ; +bus_attrs_fail: +kset_unregister (&bus->drivers); bus_drivers_fail:kset_unregister (&bus->devices); bus_devices_fail:
Signature · 1 line
1.4.2.4
PATCH 14/16 Driver core: Don't ignore error returns from probing
In reply to Greg KHFrom: Alan Stern <[email protected]>
This patch (as797) fixes device_add() in the driver core. It needs to pay attention when the driver for a new device reports an error.
At the same time, since bus_remove_device() undoes the effects of both bus_add_device() and bus_attach_device(), it needs to check whether the bus_attach_device step failed.
--- drivers/base/bus.c | 6 ++++-- drivers/base/core.c | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/base/bus.c +4 -2
@@ -439,8 +439,10 @@ void bus_remove_device(struct device * dsysfs_remove_link (&dev->kobj,"bus" );sysfs_remove_link (&dev->bus->devices.kobj, dev->bus_id);device_remove_attrs (dev->bus, dev); - dev->is_registered =0 ; -klist_del (&dev->knode_bus); +if (dev->is_registered) { + dev->is_registered =0 ; +klist_del (&dev->knode_bus); + }pr_debug ("bus %s: remove device %s\n" , dev->bus->name, dev->bus_id);device_release_driver (dev);put_bus (dev->bus);
drivers/base/core.c +4 -1
@@ -479,7 +479,8 @@ int device_add(struct device *dev)if ((error =bus_add_device (dev))) goto BusError;kobject_uevent (&dev->kobj,KOBJ_ADD ); -bus_attach_device (dev); +if ((error =bus_attach_device (dev))) + goto AttachError;if (parent)klist_add_tail (&dev->knode_parent, &parent->klist_children);
@@ -498,6 +499,8 @@ int device_add(struct device *dev)kfree (class_name);put_device (dev);return error; + AttachError: +bus_remove_device (dev); BusError:device_pm_remove (dev); PMError:
Signature · 1 line
1.4.2.4
PATCH 9/16 driver core fixes: bus_add_device() cleanup on error
In reply to Greg KHFrom: Cornelia Huck <[email protected]>
Correct cleanup in the error path of bus_add_device().
--- drivers/base/bus.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)
drivers/base/bus.c +15 -4
@@ -372,19 +372,30 @@ int bus_add_device(struct device * dev)pr_debug ("bus %s: add device %s\n" , bus->name, dev->bus_id); error =device_add_attrs (bus, dev);if (error) - goto out; + goto out_put; error =sysfs_create_link (&bus->devices.kobj, &dev->kobj, dev->bus_id);if (error) - goto out; + goto out_id; error =sysfs_create_link (&dev->kobj, &dev->bus->subsys.kset.kobj,"subsystem" );if (error) - goto out; + goto out_subsys; error =sysfs_create_link (&dev->kobj, &dev->bus->subsys.kset.kobj,"bus" ); +if (error) + goto out_deprecated; } -out: +return 0 ; + +out_deprecated: +sysfs_remove_link (&dev->kobj,"subsystem" ); +out_subsys: +sysfs_remove_link (&bus->devices.kobj, dev->bus_id); +out_id: +device_remove_attrs (bus, dev); +out_put: +put_bus (dev->bus);return error; }
Signature · 1 line
1.4.2.4
PATCH 4/16 HOWTO: bug report addition
In reply to Greg KHFrom: Diego Calleja <[email protected]>
I suspect that not many people is subscribed to the bugzilla mailing list, not surprising since the URLs doesn't seem to be in the tree :)
After fixing my english, I wonder if the following patch could be applied...
--- Documentation/HOWTO | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
Documentation/HOWTO +20 -0
@@ -395,6 +395,26 @@ bugme-janitor mailing list (every change +Managing bug reports +-------------------- + +One of the best ways to put into practice your hacking skills is by fixing +bugs reported by other people. Not only you will help to make the kernel +more stable, you'll learn to fix real world problems and you will improve +your skills, and other developers will be aware of your presence. Fixing +bugs is one of the best ways to get merits among other developers, because +not many people like wasting time fixing other people's bugs. + +To work in the already reported bug reports, go to http://bugzilla.kernel.org. +If you want to be advised of the future bug reports, you can subscribe to the +bugme-new mailing list (only new bug reports are mailed here) or to the +bugme-janitor mailing list (every change in the bugzilla is mailed here) + + http://lists.osdl.org/mailman/listinfo/bugme-new + http://lists.osdl.org/mailman/listinfo/bugme-janitors + + + Mailing lists -------------
Signature · 1 line
1.4.2.4
PATCH 1/16 Documentation: feature-removal-schedule typo
In reply to Greg KHFrom: Dominik Brodowski <[email protected]>
Fix typo in newly added feature remove schedule item.
--- Documentation/feature-removal-schedule.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/feature-removal-schedule.txt +1 -1
@@ -255,7 +255,7 @@ Who: Stephen Hemminger <shemminger@osdl. What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment -When: Oktober 2008 +When: October 2008 Why: The stacking of class devices makes these values misleading and inconsistent. Class devices should not carry any of these properties, and bus
Signature · 1 line
1.4.2.4
PATCH 11/16 driver core fixes: device_create_file() retval check in dmapool.c
In reply to Greg KHFrom: Cornelia Huck <[email protected]>
Check for device_create_file() return value in dma_pool_create().
--- drivers/base/dmapool.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)
drivers/base/dmapool.c +11 -2
@@ -141,11 +141,20 @@ dma_pool_create (const char *name, strucinit_waitqueue_head (&retval->waitq);if (dev) { +int ret; +down (&pools_lock);if (list_empty (&dev->dma_pools)) -device_create_file (dev, &dev_attr_pools); + ret =device_create_file (dev, &dev_attr_pools); +else + ret =0 ;/* note: not currently insisting "name" be unique */ -list_add (&retval->pools, &dev->dma_pools); +if (!ret) +list_add (&retval->pools, &dev->dma_pools); +else { +kfree (retval); + retval =NULL ; + }up (&pools_lock); }else INIT_LIST_HEAD (&retval->pools);
Signature · 1 line
1.4.2.4
PATCH 12/16 driver core fixes: sysfs_create_group() retval in topology.c
From: Cornelia Huck <[email protected]>
Return the return value of sysfs_create_group() in topology_add_dev().
--- drivers/base/topology.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/base/topology.c +1 -2
@@ -97,8 +97,7 @@ static struct attribute_group topology_a/* Add/Remove cpu_topology interface for CPU device */ static int __cpuinit topology_add_dev (struct sys_device * sys_dev) { -sysfs_create_group (&sys_dev->kobj, &topology_attr_group); -return 0 ; +return sysfs_create_group (&sys_dev->kobj, &topology_attr_group); }static int __cpuinit topology_remove_dev (struct sys_device * sys_dev)
Signature · 1 line
1.4.2.4
PATCH 13/16 Driver core: Don't leak 'old_class_name' in drivers/base/core.c::device_rename()
From: Jesper Juhl <[email protected]>
If kmalloc() fails to allocate space for 'old_symlink_name' in drivers/base/core.c::device_rename(), then we'll leak 'old_class_name'.
Spotted by the Coverity checker.
--- drivers/base/core.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/base/core.c +6 -3
@@ -809,8 +809,10 @@ int device_rename(struct device *dev, chif (dev->class) { old_symlink_name =kmalloc (BUS_ID_SIZE ,GFP_KERNEL ); -if (!old_symlink_name) -return -ENOMEM ; +if (!old_symlink_name) { + error = -ENOMEM ; + goto out_free_old_class; + }strlcpy (old_symlink_name, dev->bus_id,BUS_ID_SIZE ); }
@@ -834,9 +836,10 @@ int device_rename(struct device *dev, ch }put_device (dev); -kfree (old_class_name);kfree (new_class_name);kfree (old_symlink_name); + out_free_old_class: +kfree (old_class_name);return error; }
Signature · 1 line
1.4.2.4