提交 562c7cec 编写于 作者: M Mario Limonciello 提交者: Matthew Garrett

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: NMario Limonciello <mario_limonciello@dell.com>
Signed-off-by: NMatthew Garrett <matthew.garrett@nebula.com>
上级 a46ad0f1
...@@ -368,12 +368,20 @@ static int alienware_zone_init(struct platform_device *dev) ...@@ -368,12 +368,20 @@ static int alienware_zone_init(struct platform_device *dev)
zone_dev_attrs = zone_dev_attrs =
kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1), kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1),
GFP_KERNEL); GFP_KERNEL);
if (!zone_dev_attrs)
return -ENOMEM;
zone_attrs = zone_attrs =
kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2), kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2),
GFP_KERNEL); GFP_KERNEL);
if (!zone_attrs)
return -ENOMEM;
zone_data = zone_data =
kzalloc(sizeof(struct platform_zone) * (quirks->num_zones), kzalloc(sizeof(struct platform_zone) * (quirks->num_zones),
GFP_KERNEL); GFP_KERNEL);
if (!zone_data)
return -ENOMEM;
for (i = 0; i < quirks->num_zones; i++) { for (i = 0; i < quirks->num_zones; i++) {
sprintf(buffer, "zone%02X", i); sprintf(buffer, "zone%02X", i);
...@@ -546,9 +554,9 @@ module_init(alienware_wmi_init); ...@@ -546,9 +554,9 @@ module_init(alienware_wmi_init);
static void __exit alienware_wmi_exit(void) static void __exit alienware_wmi_exit(void)
{ {
alienware_zone_exit(platform_device);
remove_hdmi(platform_device);
if (platform_device) { if (platform_device) {
alienware_zone_exit(platform_device);
remove_hdmi(platform_device);
platform_device_unregister(platform_device); platform_device_unregister(platform_device);
platform_driver_unregister(&platform_driver); platform_driver_unregister(&platform_driver);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册