diff options
author | Igor Murzov <intergalactic.anonymous@gmail.com> | 2012-03-30 13:32:08 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2012-03-30 15:44:05 -0400 |
commit | ea9f8856bd6d4ed45885b06a338f7362cd6c60e5 (patch) | |
tree | 85f9eeb1d08bb3b9f22310acc0f5a15c572ee3aa /drivers/acpi | |
parent | c16fa4f2ad19908a47c63d8fa436a1178438c7e7 (diff) |
ACPI video: Harden video bus adding.
It is always better to check return values, so add some new checks and
correct existing ones.
v2: Be consistent and don't mix errors from -E* and AE_* namespaces.
Signed-off-by: Igor Murzov <e-mail@date.by>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/video.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index eaef02afc7cf..462486b9f9b2 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -548,27 +548,27 @@ acpi_video_device_EDID(struct acpi_video_device *device, | |||
548 | * 1. The system BIOS should NOT automatically control the brightness | 548 | * 1. The system BIOS should NOT automatically control the brightness |
549 | * level of the LCD when the power changes from AC to DC. | 549 | * level of the LCD when the power changes from AC to DC. |
550 | * Return Value: | 550 | * Return Value: |
551 | * -1 wrong arg. | 551 | * -EINVAL wrong arg. |
552 | */ | 552 | */ |
553 | 553 | ||
554 | static int | 554 | static int |
555 | acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) | 555 | acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) |
556 | { | 556 | { |
557 | u64 status = 0; | 557 | acpi_status status; |
558 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | 558 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; |
559 | struct acpi_object_list args = { 1, &arg0 }; | 559 | struct acpi_object_list args = { 1, &arg0 }; |
560 | 560 | ||
561 | 561 | ||
562 | if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { | 562 | if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) |
563 | status = -1; | 563 | return -EINVAL; |
564 | goto Failed; | ||
565 | } | ||
566 | arg0.integer.value = (lcd_flag << 2) | bios_flag; | 564 | arg0.integer.value = (lcd_flag << 2) | bios_flag; |
567 | video->dos_setting = arg0.integer.value; | 565 | video->dos_setting = arg0.integer.value; |
568 | acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL); | 566 | status = acpi_evaluate_object(video->device->handle, "_DOS", |
567 | &args, NULL); | ||
568 | if (ACPI_FAILURE(status)) | ||
569 | return -EIO; | ||
569 | 570 | ||
570 | Failed: | 571 | return 0; |
571 | return status; | ||
572 | } | 572 | } |
573 | 573 | ||
574 | /* | 574 | /* |
@@ -1343,15 +1343,17 @@ static int | |||
1343 | acpi_video_bus_get_devices(struct acpi_video_bus *video, | 1343 | acpi_video_bus_get_devices(struct acpi_video_bus *video, |
1344 | struct acpi_device *device) | 1344 | struct acpi_device *device) |
1345 | { | 1345 | { |
1346 | int status = 0; | 1346 | int status; |
1347 | struct acpi_device *dev; | 1347 | struct acpi_device *dev; |
1348 | 1348 | ||
1349 | acpi_video_device_enumerate(video); | 1349 | status = acpi_video_device_enumerate(video); |
1350 | if (status) | ||
1351 | return status; | ||
1350 | 1352 | ||
1351 | list_for_each_entry(dev, &device->children, node) { | 1353 | list_for_each_entry(dev, &device->children, node) { |
1352 | 1354 | ||
1353 | status = acpi_video_bus_get_one_device(dev, video); | 1355 | status = acpi_video_bus_get_one_device(dev, video); |
1354 | if (ACPI_FAILURE(status)) { | 1356 | if (status) { |
1355 | printk(KERN_WARNING PREFIX | 1357 | printk(KERN_WARNING PREFIX |
1356 | "Can't attach device\n"); | 1358 | "Can't attach device\n"); |
1357 | continue; | 1359 | continue; |
@@ -1653,8 +1655,12 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1653 | mutex_init(&video->device_list_lock); | 1655 | mutex_init(&video->device_list_lock); |
1654 | INIT_LIST_HEAD(&video->video_device_list); | 1656 | INIT_LIST_HEAD(&video->video_device_list); |
1655 | 1657 | ||
1656 | acpi_video_bus_get_devices(video, device); | 1658 | error = acpi_video_bus_get_devices(video, device); |
1657 | acpi_video_bus_start_devices(video); | 1659 | if (error) |
1660 | goto err_free_video; | ||
1661 | error = acpi_video_bus_start_devices(video); | ||
1662 | if (error) | ||
1663 | goto err_put_video; | ||
1658 | 1664 | ||
1659 | video->input = input = input_allocate_device(); | 1665 | video->input = input = input_allocate_device(); |
1660 | if (!input) { | 1666 | if (!input) { |
@@ -1692,14 +1698,19 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1692 | 1698 | ||
1693 | video->pm_nb.notifier_call = acpi_video_resume; | 1699 | video->pm_nb.notifier_call = acpi_video_resume; |
1694 | video->pm_nb.priority = 0; | 1700 | video->pm_nb.priority = 0; |
1695 | register_pm_notifier(&video->pm_nb); | 1701 | error = register_pm_notifier(&video->pm_nb); |
1702 | if (error) | ||
1703 | goto err_unregister_input_dev; | ||
1696 | 1704 | ||
1697 | return 0; | 1705 | return 0; |
1698 | 1706 | ||
1707 | err_unregister_input_dev: | ||
1708 | input_unregister_device(input); | ||
1699 | err_free_input_dev: | 1709 | err_free_input_dev: |
1700 | input_free_device(input); | 1710 | input_free_device(input); |
1701 | err_stop_video: | 1711 | err_stop_video: |
1702 | acpi_video_bus_stop_devices(video); | 1712 | acpi_video_bus_stop_devices(video); |
1713 | err_put_video: | ||
1703 | acpi_video_bus_put_devices(video); | 1714 | acpi_video_bus_put_devices(video); |
1704 | kfree(video->attached_array); | 1715 | kfree(video->attached_array); |
1705 | err_free_video: | 1716 | err_free_video: |