Skip to content

Commit

Permalink
HID: hid-uclogic-params: Invalid parameter check in uclogic_params_fr…
Browse files Browse the repository at this point in the history
…ame_init_v1_buttonpad

[ Upstream commit aa320fd ]

The function performs a check on the hdev input parameters, however, it
is used before the check.

Initialize the udev variable after the sanity check to avoid a
possible NULL pointer dereference.

Fixes: 9614219 ("HID: uclogic: Extract tablet parameter discovery into a module")
Addresses-Coverity-ID: 1443763 ("Null pointer dereference")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JoseExposito authored and gregkh committed Jan 27, 2022
1 parent 541c3a0 commit b9b5da3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/hid/hid-uclogic-params.c
Expand Up @@ -451,7 +451,7 @@ static int uclogic_params_frame_init_v1_buttonpad(
{
int rc;
bool found = false;
struct usb_device *usb_dev = hid_to_usb_dev(hdev);
struct usb_device *usb_dev;
char *str_buf = NULL;
const size_t str_len = 16;

Expand All @@ -461,6 +461,8 @@ static int uclogic_params_frame_init_v1_buttonpad(
goto cleanup;
}

usb_dev = hid_to_usb_dev(hdev);

/*
* Enable generic button mode
*/
Expand Down

0 comments on commit b9b5da3

Please sign in to comment.