Commit 45036ae1 authored by Axel Lin's avatar Axel Lin Committed by Matthew Garrett

asus-laptop: fix asus_input_init error path

This patch includes below fixes:
1. return -ENOMEM instead of 0 if input_allocate_device fail.
2. fix wrong goto if sparse_keymap_setup fail.
3. fix wrong goto if input_register_device fail.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
parent 8700e161
...@@ -1124,7 +1124,7 @@ static int asus_input_init(struct asus_laptop *asus) ...@@ -1124,7 +1124,7 @@ static int asus_input_init(struct asus_laptop *asus)
input = input_allocate_device(); input = input_allocate_device();
if (!input) { if (!input) {
pr_info("Unable to allocate input device\n"); pr_info("Unable to allocate input device\n");
return 0; return -ENOMEM;
} }
input->name = "Asus Laptop extra buttons"; input->name = "Asus Laptop extra buttons";
input->phys = ASUS_LAPTOP_FILE "/input0"; input->phys = ASUS_LAPTOP_FILE "/input0";
...@@ -1135,20 +1135,20 @@ static int asus_input_init(struct asus_laptop *asus) ...@@ -1135,20 +1135,20 @@ static int asus_input_init(struct asus_laptop *asus)
error = sparse_keymap_setup(input, asus_keymap, NULL); error = sparse_keymap_setup(input, asus_keymap, NULL);
if (error) { if (error) {
pr_err("Unable to setup input device keymap\n"); pr_err("Unable to setup input device keymap\n");
goto err_keymap; goto err_free_dev;
} }
error = input_register_device(input); error = input_register_device(input);
if (error) { if (error) {
pr_info("Unable to register input device\n"); pr_info("Unable to register input device\n");
goto err_device; goto err_free_keymap;
} }
asus->inputdev = input; asus->inputdev = input;
return 0; return 0;
err_keymap: err_free_keymap:
sparse_keymap_free(input); sparse_keymap_free(input);
err_device: err_free_dev:
input_free_device(input); input_free_device(input);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment