ACPI / sysfs: correctly check failing memory allocation
authorInsu Yun <wuninsu@gmail.com>
Thu, 15 Oct 2015 16:19:30 +0000 (12:19 -0400)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 26 Oct 2015 03:57:27 +0000 (04:57 +0100)
Since kobject_create_and_add() can fail under memory pressure,
its return value needs to be checked against NULL before passing
it to sysfs_create_file().

Signed-off-by: Insu Yun <wuninsu@gmail.com>
[ rjw: Subject & changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/sysfs.c

index 40a4265..0243d37 100644 (file)
@@ -878,6 +878,9 @@ int __init acpi_sysfs_init(void)
                return result;
 
        hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj);
+       if (!hotplug_kobj)
+               return -ENOMEM;
+
        result = sysfs_create_file(hotplug_kobj, &force_remove_attr.attr);
        if (result)
                return result;