diff options
author | Mario Limonciello <mario_limonciello@dell.com> | 2014-04-04 21:40:20 +0200 |
---|---|---|
committer | Matthew Garrett <matthew.garrett@nebula.com> | 2014-04-10 18:11:56 +0200 |
commit | 562c7cec1e92be85ade6f65fff107651e10ee2ed (patch) | |
tree | 5b84c1525c05563990c2397300881fef0f06d409 /drivers/platform | |
parent | Add WMI driver for controlling AlienFX features on some Alienware products (diff) | |
download | linux-562c7cec1e92be85ade6f65fff107651e10ee2ed.tar.xz linux-562c7cec1e92be85ade6f65fff107651e10ee2ed.zip |
alienware-wmi: cover some scenarios where memory allocations would fail
Intel test builder caught a few instances that should test if kzalloc failed to
allocate memory as well as a scenario that platform_driver wasn't properly
initialized.
Signed-off-by: Mario Limonciello <mario_limonciello@dell.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/alienware-wmi.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c index 3e17e996021c..541f9514f76f 100644 --- a/drivers/platform/x86/alienware-wmi.c +++ b/drivers/platform/x86/alienware-wmi.c @@ -368,12 +368,20 @@ static int alienware_zone_init(struct platform_device *dev) zone_dev_attrs = kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1), GFP_KERNEL); + if (!zone_dev_attrs) + return -ENOMEM; + zone_attrs = kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2), GFP_KERNEL); + if (!zone_attrs) + return -ENOMEM; + zone_data = kzalloc(sizeof(struct platform_zone) * (quirks->num_zones), GFP_KERNEL); + if (!zone_data) + return -ENOMEM; for (i = 0; i < quirks->num_zones; i++) { sprintf(buffer, "zone%02X", i); @@ -546,9 +554,9 @@ module_init(alienware_wmi_init); static void __exit alienware_wmi_exit(void) { - alienware_zone_exit(platform_device); - remove_hdmi(platform_device); if (platform_device) { + alienware_zone_exit(platform_device); + remove_hdmi(platform_device); platform_device_unregister(platform_device); platform_driver_unregister(&platform_driver); } |