HID: alps: fix error return code in alps_input_configured()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Thu, 4 Mar 2021 13:19:57 +0000 (05:19 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Apr 2021 11:19:15 +0000 (13:19 +0200)
[ Upstream commit fa8ba6e5dc0e78e409e503ddcfceef5dd96527f4 ]

When input_register_device() fails, no error return code is assigned.
To fix this bug, ret is assigned with -ENOENT as error return code.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/hid-alps.c

index d33f5abc8f64d271bbd998801273e3aa1cb691f3..2477b2a3f7c3ab9d6de8bcd6ef0dc14908f3e742 100644 (file)
@@ -762,6 +762,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
 
                if (input_register_device(data->input2)) {
                        input_free_device(input2);
+                       ret = -ENOENT;
                        goto exit;
                }
        }