From: Insu Yun Date: Thu, 15 Oct 2015 16:19:30 +0000 (-0400) Subject: ACPI / sysfs: correctly check failing memory allocation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bc1e49df345cf9be38ba29ead45a12f86ceb5fe2;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git ACPI / sysfs: correctly check failing memory allocation 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 [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 40a42655227c..0243d375c6fd 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -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;