HID: alps: fix error return code in alps_input_configured()
authorWei Yongjun <weiyongjun1@huawei.com>
Wed, 21 Sep 2016 15:12:05 +0000 (15:12 +0000)
committerJiri Kosina <jkosina@suse.cz>
Thu, 22 Sep 2016 09:10:06 +0000 (11:10 +0200)
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

While at it, remove redundant input_free_device(NULL) call.

[jkosina@suse.cz: ammend changelog]
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-alps.c

index 048befde295a2f79e8c847b87f7aebd0b93d7c0c..0c18d473a5d84f5d8d7caa19347d91c2a3c95eb8 100644 (file)
@@ -383,7 +383,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
 
                input2 = input_allocate_device();
                if (!input2) {
-                       input_free_device(input2);
+                       ret = -ENOMEM;
                        goto exit;
                }
 
@@ -425,7 +425,8 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
                __set_bit(INPUT_PROP_POINTER, input2->propbit);
                __set_bit(INPUT_PROP_POINTING_STICK, input2->propbit);
 
-               if (input_register_device(data->input2)) {
+               ret = input_register_device(data->input2);
+               if (ret) {
                        input_free_device(input2);
                        goto exit;
                }