Skip to contentSkip to conversation

acpi:correctly check failed allocation

PATCH In review Insu Yun 2 participants 2 messages Oct 15, 2015 – Oct 28, 2015 ACPI

lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 acpi:correctly check failed allocation

Since kobject_create_and_add can be failed in memory pressure, return value need to be checked and return ENOMEM.

---
 drivers/acpi/sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/acpi/sysfs.c +2 -0
index 40a4265..e712a7b 100644
@@ -878,6 +878,8 @@ 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;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 14 lines · Insu Yun

Since kobject_create_and_add can be failed in memory pressure, return value need to be checked and return ENOMEM.

---
 drivers/acpi/sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/acpi/sysfs.c +0 -0
index 40a4265..e712a7b 100644

drivers/acpi/sysfs.c int __init acpi_sysfs_init(void) · line 885

Quoted 8 lines
drivers/acpi/sysfs.c +2 -0
@@ -878,6 +878,8 @@ 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;

Applied (with whitespace fixed), thanks!

Rafael