summaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorJosé Expósito <jose.exposito89@gmail.com>2022-01-05 18:29:13 +0100
committerJiri Kosina <jkosina@suse.cz>2022-01-06 15:39:43 +0100
commit0a94131d6920916ccb6a357037c535533af08819 (patch)
tree1680487c5cf5d2131ea02adc4dbce990d6219af9 /drivers/hid
parentf364c571a5c77e96de2d32062ff019d6b8d2e2bc (diff)
downloadlinux-0a94131d6920916ccb6a357037c535533af08819.tar.gz
linux-0a94131d6920916ccb6a357037c535533af08819.tar.bz2
linux-0a94131d6920916ccb6a357037c535533af08819.zip
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: 9614219e9310e ("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>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-uclogic-params.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 3c10b858cf74..3a83e2c39b4f 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -66,7 +66,7 @@ static int uclogic_params_get_str_desc(__u8 **pbuf, struct hid_device *hdev,
__u8 idx, size_t len)
{
int rc;
- struct usb_device *udev = hid_to_usb_dev(hdev);
+ struct usb_device *udev;
__u8 *buf = NULL;
/* Check arguments */
@@ -75,6 +75,8 @@ static int uclogic_params_get_str_desc(__u8 **pbuf, struct hid_device *hdev,
goto cleanup;
}
+ udev = hid_to_usb_dev(hdev);
+
buf = kmalloc(len, GFP_KERNEL);
if (buf == NULL) {
rc = -ENOMEM;