diff options
author | Mario Limonciello <mario_limonciello@dell.com> | 2014-04-04 15:40:20 -0400 |
---|---|---|
committer | Matthew Garrett <matthew.garrett@nebula.com> | 2014-04-10 12:11:56 -0400 |
commit | 562c7cec1e92be85ade6f65fff107651e10ee2ed (patch) | |
tree | 5b84c1525c05563990c2397300881fef0f06d409 /drivers/platform | |
parent | a46ad0f13bc32a9601f3c5dff43fafdc2c598814 (diff) |
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) | |||
368 | zone_dev_attrs = | 368 | zone_dev_attrs = |
369 | kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1), | 369 | kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1), |
370 | GFP_KERNEL); | 370 | GFP_KERNEL); |
371 | if (!zone_dev_attrs) | ||
372 | return -ENOMEM; | ||
373 | |||
371 | zone_attrs = | 374 | zone_attrs = |
372 | kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2), | 375 | kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2), |
373 | GFP_KERNEL); | 376 | GFP_KERNEL); |
377 | if (!zone_attrs) | ||
378 | return -ENOMEM; | ||
379 | |||
374 | zone_data = | 380 | zone_data = |
375 | kzalloc(sizeof(struct platform_zone) * (quirks->num_zones), | 381 | kzalloc(sizeof(struct platform_zone) * (quirks->num_zones), |
376 | GFP_KERNEL); | 382 | GFP_KERNEL); |
383 | if (!zone_data) | ||
384 | return -ENOMEM; | ||
377 | 385 | ||
378 | for (i = 0; i < quirks->num_zones; i++) { | 386 | for (i = 0; i < quirks->num_zones; i++) { |
379 | sprintf(buffer, "zone%02X", i); | 387 | sprintf(buffer, "zone%02X", i); |
@@ -546,9 +554,9 @@ module_init(alienware_wmi_init); | |||
546 | 554 | ||
547 | static void __exit alienware_wmi_exit(void) | 555 | static void __exit alienware_wmi_exit(void) |
548 | { | 556 | { |
549 | alienware_zone_exit(platform_device); | ||
550 | remove_hdmi(platform_device); | ||
551 | if (platform_device) { | 557 | if (platform_device) { |
558 | alienware_zone_exit(platform_device); | ||
559 | remove_hdmi(platform_device); | ||
552 | platform_device_unregister(platform_device); | 560 | platform_device_unregister(platform_device); |
553 | platform_driver_unregister(&platform_driver); | 561 | platform_driver_unregister(&platform_driver); |
554 | } | 562 | } |