The patch titled driver core fixes: make_class_name() retval check has been added to the -mm tree. Its filename is driver-core-fixes-make_class_name-retval-check.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: driver core fixes: make_class_name() retval check From: Cornelia Huck <cornelia.huck@xxxxxxxxxx> Make make_class_name() return NULL on error and fixup callers in the driver core. Signed-off-by: Cornelia Huck <cornelia.huck@xxxxxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- drivers/base/class.c | 21 +++++++++++++-------- drivers/base/core.c | 14 ++++++++++---- 2 files changed, 23 insertions(+), 12 deletions(-) diff -puN drivers/base/class.c~driver-core-fixes-make_class_name-retval-check drivers/base/class.c --- a/drivers/base/class.c~driver-core-fixes-make_class_name-retval-check +++ a/drivers/base/class.c @@ -515,7 +515,7 @@ char *make_class_name(const char *name, class_name = kmalloc(size, GFP_KERNEL); if (!class_name) - return ERR_PTR(-ENOMEM); + return NULL; strcpy(class_name, name); strcat(class_name, ":"); @@ -598,8 +598,11 @@ int class_device_add(struct class_device if (class_dev->dev) { class_name = make_class_name(class_dev->class->name, &class_dev->kobj); - error = sysfs_create_link(&class_dev->kobj, - &class_dev->dev->kobj, "device"); + if (class_name) + error = sysfs_create_link(&class_dev->kobj, + &class_dev->dev->kobj, "device"); + else + error = -ENOMEM; if (error) goto out6; error = sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, @@ -723,7 +726,6 @@ void class_device_del(struct class_devic struct class *parent_class = class_dev->class; struct class_device *parent_device = class_dev->parent; struct class_interface *class_intf; - char *class_name = NULL; if (parent_class) { down(&parent_class->sem); @@ -735,10 +737,12 @@ void class_device_del(struct class_devic } if (class_dev->dev) { - class_name = make_class_name(class_dev->class->name, + char *class_name = make_class_name(class_dev->class->name, &class_dev->kobj); sysfs_remove_link(&class_dev->kobj, "device"); - sysfs_remove_link(&class_dev->dev->kobj, class_name); + if (class_name) + sysfs_remove_link(&class_dev->dev->kobj, class_name); + kfree(class_name); } sysfs_remove_link(&class_dev->kobj, "subsystem"); class_device_remove_file(class_dev, &class_dev->uevent_attr); @@ -752,7 +756,6 @@ void class_device_del(struct class_devic class_device_put(parent_device); class_put(parent_class); - kfree(class_name); } void class_device_unregister(struct class_device *class_dev) @@ -814,7 +817,9 @@ int class_device_rename(struct class_dev &class_dev->kobj); sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, new_class_name); - sysfs_remove_link(&class_dev->dev->kobj, old_class_name); + if (old_class_name) + sysfs_remove_link(&class_dev->dev->kobj, + old_class_name); } class_device_put(class_dev); diff -puN drivers/base/core.c~driver-core-fixes-make_class_name-retval-check drivers/base/core.c --- a/drivers/base/core.c~driver-core-fixes-make_class_name-retval-check +++ a/drivers/base/core.c @@ -462,9 +462,13 @@ int device_add(struct device *dev) sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, dev->bus_id); if (parent) { - sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); - class_name = make_class_name(dev->class->name, &dev->kobj); - sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); + sysfs_create_link(&dev->kobj, &dev->parent->kobj, + "device"); + class_name = make_class_name(dev->class->name, + &dev->kobj); + if (class_name) + sysfs_create_link(&dev->parent->kobj, + &dev->kobj, class_name); } } @@ -593,7 +597,9 @@ void device_del(struct device * dev) class_name = make_class_name(dev->class->name, &dev->kobj); if (parent) { sysfs_remove_link(&dev->kobj, "device"); - sysfs_remove_link(&dev->parent->kobj, class_name); + if (class_name) + sysfs_remove_link(&dev->parent->kobj, + class_name); } kfree(class_name); down(&dev->class->sem); _ Patches currently in -mm which might be from cornelia.huck@xxxxxxxxxx are driver-core-fixes-make_class_name-retval-check.patch driver-core-fixes-device_register-retval-check-in.patch driver-core-fixes-sysfs_create_link-retval-check-in.patch driver-core-fixes-bus_add_attrs-retval-check.patch driver-core-fixes-bus_add_device-cleanup-on-error.patch driver-core-fixes-device_add-cleanup-on-error.patch driver-core-fixes-device_create_file-retval-check-in.patch driver-core-fixes-sysfs_create_group-retval-in-topologyc.patch git-s390.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html