diff options
author | José Expósito <jose.exposito89@gmail.com> | 2022-01-05 20:29:13 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-01-27 12:54:02 +0300 |
commit | c47f842e0c3c105073fa5a9edd6ae9c6ca8383ce (patch) | |
tree | 1a2f7f45bdf9f0a6c02ee22aa24a8654671ec4e3 /drivers/hid | |
parent | cf5ad827ee696a134b8f2d65162989be8cf7188d (diff) | |
download | linux-c47f842e0c3c105073fa5a9edd6ae9c6ca8383ce.tar.xz |
HID: hid-uclogic-params: Invalid parameter check in uclogic_params_get_str_desc
[ Upstream commit 0a94131d6920916ccb6a357037c535533af08819 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-uclogic-params.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 851ab8e24f9d..a751c9a49360 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -65,7 +65,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 */ @@ -74,6 +74,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; |