diff options
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r-- | drivers/base/class.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 8bf2ca2e56b5..96def1ddba19 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -364,7 +364,7 @@ char *make_class_name(const char *name, struct kobject *kobj) | |||
364 | 364 | ||
365 | class_name = kmalloc(size, GFP_KERNEL); | 365 | class_name = kmalloc(size, GFP_KERNEL); |
366 | if (!class_name) | 366 | if (!class_name) |
367 | return ERR_PTR(-ENOMEM); | 367 | return NULL; |
368 | 368 | ||
369 | strcpy(class_name, name); | 369 | strcpy(class_name, name); |
370 | strcat(class_name, ":"); | 370 | strcat(class_name, ":"); |
@@ -411,8 +411,11 @@ static int make_deprecated_class_device_links(struct class_device *class_dev) | |||
411 | return 0; | 411 | return 0; |
412 | 412 | ||
413 | class_name = make_class_name(class_dev->class->name, &class_dev->kobj); | 413 | class_name = make_class_name(class_dev->class->name, &class_dev->kobj); |
414 | error = sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, | 414 | if (class_name) |
415 | class_name); | 415 | error = sysfs_create_link(&class_dev->dev->kobj, |
416 | &class_dev->kobj, class_name); | ||
417 | else | ||
418 | error = -ENOMEM; | ||
416 | kfree(class_name); | 419 | kfree(class_name); |
417 | return error; | 420 | return error; |
418 | } | 421 | } |
@@ -425,7 +428,8 @@ static void remove_deprecated_class_device_links(struct class_device *class_dev) | |||
425 | return; | 428 | return; |
426 | 429 | ||
427 | class_name = make_class_name(class_dev->class->name, &class_dev->kobj); | 430 | class_name = make_class_name(class_dev->class->name, &class_dev->kobj); |
428 | sysfs_remove_link(&class_dev->dev->kobj, class_name); | 431 | if (class_name) |
432 | sysfs_remove_link(&class_dev->dev->kobj, class_name); | ||
429 | kfree(class_name); | 433 | kfree(class_name); |
430 | } | 434 | } |
431 | #else | 435 | #else |
@@ -863,9 +867,12 @@ int class_device_rename(struct class_device *class_dev, char *new_name) | |||
863 | if (class_dev->dev) { | 867 | if (class_dev->dev) { |
864 | new_class_name = make_class_name(class_dev->class->name, | 868 | new_class_name = make_class_name(class_dev->class->name, |
865 | &class_dev->kobj); | 869 | &class_dev->kobj); |
866 | sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, | 870 | if (new_class_name) |
867 | new_class_name); | 871 | sysfs_create_link(&class_dev->dev->kobj, |
868 | sysfs_remove_link(&class_dev->dev->kobj, old_class_name); | 872 | &class_dev->kobj, new_class_name); |
873 | if (old_class_name) | ||
874 | sysfs_remove_link(&class_dev->dev->kobj, | ||
875 | old_class_name); | ||
869 | } | 876 | } |
870 | #endif | 877 | #endif |
871 | class_device_put(class_dev); | 878 | class_device_put(class_dev); |