Skip to content

Commit 0a94131

Browse files
JoseExpositoJiri Kosina
authored andcommitted
HID: hid-uclogic-params: Invalid parameter check in uclogic_params_get_str_desc
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: 1443827 ("Null pointer dereference") Signed-off-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent f364c57 commit 0a94131

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/hid/hid-uclogic-params.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int uclogic_params_get_str_desc(__u8 **pbuf, struct hid_device *hdev,
6666
__u8 idx, size_t len)
6767
{
6868
int rc;
69-
struct usb_device *udev = hid_to_usb_dev(hdev);
69+
struct usb_device *udev;
7070
__u8 *buf = NULL;
7171

7272
/* Check arguments */
@@ -75,6 +75,8 @@ static int uclogic_params_get_str_desc(__u8 **pbuf, struct hid_device *hdev,
7575
goto cleanup;
7676
}
7777

78+
udev = hid_to_usb_dev(hdev);
79+
7880
buf = kmalloc(len, GFP_KERNEL);
7981
if (buf == NULL) {
8082
rc = -ENOMEM;

0 commit comments

Comments
 (0)