mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 07:00:48 +00:00
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>
This commit is contained in:
parent
c16fa4f2ad
commit
ea9f8856bd
@ -548,27 +548,27 @@ acpi_video_device_EDID(struct acpi_video_device *device,
|
|||||||
* 1. The system BIOS should NOT automatically control the brightness
|
* 1. The system BIOS should NOT automatically control the brightness
|
||||||
* level of the LCD when the power changes from AC to DC.
|
* level of the LCD when the power changes from AC to DC.
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* -1 wrong arg.
|
* -EINVAL wrong arg.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
|
acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
|
||||||
{
|
{
|
||||||
u64 status = 0;
|
acpi_status status;
|
||||||
union acpi_object arg0 = { ACPI_TYPE_INTEGER };
|
union acpi_object arg0 = { ACPI_TYPE_INTEGER };
|
||||||
struct acpi_object_list args = { 1, &arg0 };
|
struct acpi_object_list args = { 1, &arg0 };
|
||||||
|
|
||||||
|
|
||||||
if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
|
if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1)
|
||||||
status = -1;
|
return -EINVAL;
|
||||||
goto Failed;
|
|
||||||
}
|
|
||||||
arg0.integer.value = (lcd_flag << 2) | bios_flag;
|
arg0.integer.value = (lcd_flag << 2) | bios_flag;
|
||||||
video->dos_setting = arg0.integer.value;
|
video->dos_setting = arg0.integer.value;
|
||||||
acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
|
status = acpi_evaluate_object(video->device->handle, "_DOS",
|
||||||
|
&args, NULL);
|
||||||
|
if (ACPI_FAILURE(status))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
Failed:
|
return 0;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1343,15 +1343,17 @@ static int
|
|||||||
acpi_video_bus_get_devices(struct acpi_video_bus *video,
|
acpi_video_bus_get_devices(struct acpi_video_bus *video,
|
||||||
struct acpi_device *device)
|
struct acpi_device *device)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status;
|
||||||
struct acpi_device *dev;
|
struct acpi_device *dev;
|
||||||
|
|
||||||
acpi_video_device_enumerate(video);
|
status = acpi_video_device_enumerate(video);
|
||||||
|
if (status)
|
||||||
|
return status;
|
||||||
|
|
||||||
list_for_each_entry(dev, &device->children, node) {
|
list_for_each_entry(dev, &device->children, node) {
|
||||||
|
|
||||||
status = acpi_video_bus_get_one_device(dev, video);
|
status = acpi_video_bus_get_one_device(dev, video);
|
||||||
if (ACPI_FAILURE(status)) {
|
if (status) {
|
||||||
printk(KERN_WARNING PREFIX
|
printk(KERN_WARNING PREFIX
|
||||||
"Can't attach device\n");
|
"Can't attach device\n");
|
||||||
continue;
|
continue;
|
||||||
@ -1653,8 +1655,12 @@ static int acpi_video_bus_add(struct acpi_device *device)
|
|||||||
mutex_init(&video->device_list_lock);
|
mutex_init(&video->device_list_lock);
|
||||||
INIT_LIST_HEAD(&video->video_device_list);
|
INIT_LIST_HEAD(&video->video_device_list);
|
||||||
|
|
||||||
acpi_video_bus_get_devices(video, device);
|
error = acpi_video_bus_get_devices(video, device);
|
||||||
acpi_video_bus_start_devices(video);
|
if (error)
|
||||||
|
goto err_free_video;
|
||||||
|
error = acpi_video_bus_start_devices(video);
|
||||||
|
if (error)
|
||||||
|
goto err_put_video;
|
||||||
|
|
||||||
video->input = input = input_allocate_device();
|
video->input = input = input_allocate_device();
|
||||||
if (!input) {
|
if (!input) {
|
||||||
@ -1692,14 +1698,19 @@ static int acpi_video_bus_add(struct acpi_device *device)
|
|||||||
|
|
||||||
video->pm_nb.notifier_call = acpi_video_resume;
|
video->pm_nb.notifier_call = acpi_video_resume;
|
||||||
video->pm_nb.priority = 0;
|
video->pm_nb.priority = 0;
|
||||||
register_pm_notifier(&video->pm_nb);
|
error = register_pm_notifier(&video->pm_nb);
|
||||||
|
if (error)
|
||||||
|
goto err_unregister_input_dev;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_unregister_input_dev:
|
||||||
|
input_unregister_device(input);
|
||||||
err_free_input_dev:
|
err_free_input_dev:
|
||||||
input_free_device(input);
|
input_free_device(input);
|
||||||
err_stop_video:
|
err_stop_video:
|
||||||
acpi_video_bus_stop_devices(video);
|
acpi_video_bus_stop_devices(video);
|
||||||
|
err_put_video:
|
||||||
acpi_video_bus_put_devices(video);
|
acpi_video_bus_put_devices(video);
|
||||||
kfree(video->attached_array);
|
kfree(video->attached_array);
|
||||||
err_free_video:
|
err_free_video:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user