summaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorInsu Yun <wuninsu@gmail.com>2015-10-15 12:19:30 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-10-26 04:57:27 +0100
commitbc1e49df345cf9be38ba29ead45a12f86ceb5fe2 (patch)
treeee949ea50dcb7c65f87789c0ec5b33de8b95c871 /drivers/acpi
parentf934c745079ea3a15e8619350faf681dad42cc91 (diff)
downloadlinux-bc1e49df345cf9be38ba29ead45a12f86ceb5fe2.tar.bz2
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 <wuninsu@gmail.com> [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/sysfs.c3
1 files changed, 3 insertions, 0 deletions
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;