HID: alps: Fix an error handling path in 'alps_input_configured()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 4 Dec 2019 03:35:25 +0000 (04:35 +0100)
committerJiri Kosina <jkosina@suse.cz>
Wed, 12 Feb 2020 14:06:19 +0000 (15:06 +0100)
They are issues:
   - if 'input_allocate_device()' fails and return NULL, there is no need
     to free anything and 'input_free_device()' call is a no-op. It can
     be axed.
   - 'ret' is known to be 0 at this point, so we must set it to a
     meaningful value before returning

Fixes: 2562756dde55 ("HID: add Alps I2C HID Touchpad-Stick support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-alps.c

index ae79a7c667372e6e54b8302565870c3f24b2ce85..fa704153cb00d5f7fa7d0185acd1f953fdd37754 100644 (file)
@@ -730,7 +730,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)
        if (data->has_sp) {
                input2 = input_allocate_device();
                if (!input2) {
-                       input_free_device(input2);
+                       ret = -ENOMEM;
                        goto exit;
                }