From patchwork Wed Jan 5 17:29:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12704552 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1C5FC433EF for ; Wed, 5 Jan 2022 17:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242262AbiAER30 (ORCPT ); Wed, 5 Jan 2022 12:29:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242235AbiAER3Z (ORCPT ); Wed, 5 Jan 2022 12:29:25 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E405C061245; Wed, 5 Jan 2022 09:29:25 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so3710647wme.4; Wed, 05 Jan 2022 09:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=76j/vBihwnF+1b+6Vi7Z9v34SJGyorcIi5qbktRYn7M=; b=PAiO7xpn9cR7fCzoh02uoNu36k52dnHGWus+w9e1kg0BKjaLo7XMfT7m5jv7Vo0yOi bCZIMCWQ5KKv4HuNuI/jTaI3jt/C2eKTuvh2YnpM1sO2FAI/LIMCA2S3pWHU6DkJlv6W 3vLph53A9mVICKhb5zw3IA9806wY+zORKlPH0Tx4xP+W8QbTWCa/CvFnmiGljjKrtivF NBmrHTPVinfq2oZKPDi6kT3et5vq62LiEcV5Ty82Nn627VgiVbLTvTKHwz7+5Zh4a6f+ vsSY3db0oZW3ufUAaYjFl3qxL7MLKdY8TyKvaEL+xPkCH05VaCyBDQYC7//lZChVXx8+ fAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=76j/vBihwnF+1b+6Vi7Z9v34SJGyorcIi5qbktRYn7M=; b=7lFdVKHGpgydTeg1QVkLq6X2YUmtJKQ8eyqkTLjAJyJXAvZ2OMVTe0XmwoLxOQ4nEQ HNaf92gp5DqDAq5XeID/iKblQEpyzk5zgsw6waHXWQ5E9Hu5/Ann/3GvLxJq//f7hcex +8OmDn9G8qmt6NQiw22wxrbzNnnHECn/JS5tI6yhMHT3XBnmaIKwZicm0Zc4znOqz9gR xlws2EM8cd+jAdcq3/kRx+Te1Y9A1lLLFAe6Ia8iPxon4dlvlcOyXz0u9t28h13z8OY0 d23ylfdSNh01UYOLPy8uU/lC+a+CaPPJB/kIH+rzm5MveG4wsARybRvEclKfQXLjwoY2 OPaQ== X-Gm-Message-State: AOAM533cl8n1NnVhBxoSNq46UOrlyucCF8AJveJn/NPUtMvNHgIfDdNl eL2mhYK3FBHA0UX4tPMjqYY= X-Google-Smtp-Source: ABdhPJxpJk51idyGNT2hPNI07YNoQmi5SEQ2ysX1wo3u1Q7fD5HPriWyw04A1WGVm7cTWAzToPKomA== X-Received: by 2002:a1c:a747:: with SMTP id q68mr2491100wme.98.1641403763651; Wed, 05 Jan 2022 09:29:23 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id g6sm43071442wri.67.2022.01.05.09.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 09:29:23 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, spbnick@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH 1/4] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_init Date: Wed, 5 Jan 2022 18:29:12 +0100 Message-Id: <20220105172915.131091-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220105172915.131091-1-jose.exposito89@gmail.com> References: <20220105172915.131091-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The function performs a check on its input parameters, however, the hdev parameter is used before the check. Initialize the stack variables after checking the input parameters to avoid a possible NULL pointer dereference. Fixes: 9614219e9310e ("HID: uclogic: Extract tablet parameter discovery into a module") Addresses-Coverity-ID: 1443831 ("Null pointer dereference") Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index adff1bd68d9f..3c10b858cf74 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -834,10 +834,10 @@ int uclogic_params_init(struct uclogic_params *params, struct hid_device *hdev) { int rc; - struct usb_device *udev = hid_to_usb_dev(hdev); - __u8 bNumInterfaces = udev->config->desc.bNumInterfaces; - struct usb_interface *iface = to_usb_interface(hdev->dev.parent); - __u8 bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; + struct usb_device *udev; + __u8 bNumInterfaces; + struct usb_interface *iface; + __u8 bInterfaceNumber; bool found; /* The resulting parameters (noop) */ struct uclogic_params p = {0, }; @@ -848,6 +848,11 @@ int uclogic_params_init(struct uclogic_params *params, goto cleanup; } + udev = hid_to_usb_dev(hdev); + bNumInterfaces = udev->config->desc.bNumInterfaces; + iface = to_usb_interface(hdev->dev.parent); + bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; + /* * Set replacement report descriptor if the original matches the * specified size. Otherwise keep interface unchanged. From patchwork Wed Jan 5 17:29:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12704553 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC157C433F5 for ; Wed, 5 Jan 2022 17:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242268AbiAER32 (ORCPT ); Wed, 5 Jan 2022 12:29:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242269AbiAER31 (ORCPT ); Wed, 5 Jan 2022 12:29:27 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F822C061245; Wed, 5 Jan 2022 09:29:26 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id o3so26318392wrh.10; Wed, 05 Jan 2022 09:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mislRvWvSm9MQvo2DuLYAbpGhpBV7rP9idLOw8BlRh8=; b=YjLV5zr+sk+iKrzT+BMdnFUDzjG1220eB/Gwlw3ZqLLy29PS2ZqGUzKAA1C5Koh5FD 55sY3m3A2mMh7oIm+0xGml8Yf5AJ2tv2OLvovLmMDDJL0YIBKkekpJvV5Cpqzsl1JbSh +okK/xrORSlJap7SRWIGLCQO0WQiC7/y7tt6WQOPSKGsLSATZpZWo0BYdFoMHvRy+GW1 VkqJccxoukFnj6KTV9osNdiEJBse8kJ7fJB+CldKLTspO8bhJPyu8RkuDvwsqBeQskjd WByu2oT7U3kLJa1bIl4XW+PRFWNwGsq7q3dJhM1e6/2enpF/8x6s01etN43jOGQWeHro Ohqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mislRvWvSm9MQvo2DuLYAbpGhpBV7rP9idLOw8BlRh8=; b=CE+ZkOfyqlItLnH3Y1EQ/tCFZ4JkMIlm81D9Rfz/Nmh/Mz4BIrNSqsr+vh3WOBH8/b e7SC4Pt/nTjw/6ZFdVShVvmba0W0qqKVIPQj8QQX0qttrcqpGH8CKMNKxLH1Q62uBFIi qLGpGhHKlfeFE1yqNfKzG/72ijzlg8wQwlgxs39EhKbQ2+A/RO1/PmifpdXjhpqLT/cm qrvW5Ze4u5LlWKC8JwdWlhgrAPlNrO1leFxej266vpUY8OjLTVvgp57hxTR4/OjRKER6 6srrpR2RNgdDZ+ruLnWHwfyF7heBayvAcXA4EX56U7UuSWbgQphp4ouKjp3KWEDhfWL9 hs9Q== X-Gm-Message-State: AOAM530i4LCPqEOHBN9XMDZLCv61ArLfYOtb8jZwHEA39k1bHiet2C3B WtEzybELvdj355spn7+MHGQ= X-Google-Smtp-Source: ABdhPJzY2mjFA2TSoOhJs8T8YWWy17fDTaWlr4dngcV+O5iSK3tVuF/LEU13Rv/7jzFrehQzhZ+83A== X-Received: by 2002:a5d:64a7:: with SMTP id m7mr46391357wrp.687.1641403765287; Wed, 05 Jan 2022 09:29:25 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id g6sm43071442wri.67.2022.01.05.09.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 09:29:24 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, spbnick@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH 2/4] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_get_str_desc Date: Wed, 5 Jan 2022 18:29:13 +0100 Message-Id: <20220105172915.131091-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220105172915.131091-1-jose.exposito89@gmail.com> References: <20220105172915.131091-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 --- drivers/hid/hid-uclogic-params.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; From patchwork Wed Jan 5 17:29:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12704554 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9467C433F5 for ; Wed, 5 Jan 2022 17:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242260AbiAER3d (ORCPT ); Wed, 5 Jan 2022 12:29:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242273AbiAER33 (ORCPT ); Wed, 5 Jan 2022 12:29:29 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E03CC061245; Wed, 5 Jan 2022 09:29:29 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id j18so84495851wrd.2; Wed, 05 Jan 2022 09:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EwC0zb6TsDRNr+wrSu8k3dQNGNsYgW/0Ss/SRNaNxkI=; b=beLHVYce21VNdAuj3elbE3gbFn4pMqPAHJW8M2rosz4scHjk7UjfvHD5jQ1F93Hu4l j06wLMd08kIPtTe1QpVIWMxHnFsznNRvg2bdgYoxylrmaiexGIlQPfBi53kS6DEgeP5L SawgGXWPtF8LRHLch0HwxOjFBku6v2s2dbycrBkkCtGhbuate1tFWi4Y3WW1eefafNXd hceRZlZ2wosPe2Kson/555K3xwdF2wVXV2QbN9Cs3oDAll9b3e8PrErz0kkd8arAS4AM GM2sbqPcZOfenqviqNYtsfWDzZv/RRDRyraaB/AY1hkABJzVwCsAjclAByr6TEw+amcd M/8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EwC0zb6TsDRNr+wrSu8k3dQNGNsYgW/0Ss/SRNaNxkI=; b=mCq7OiK/0FdYUlGF/066FVZGbKyDq3oTWr7q184U4XPAH00bwvl2DbUkzLemtuxPLb LyZeWEylHGFU54eE+qd7nL6NDiAS8P1SsvLZORfKwVLoG9nsuMxQnvb+NGEZ8HrdgsS8 Fbui71PN6byYM/xxW2eYOAKhwR6usMA2srDXkToth9Aah+w09Ygr7lW7+i9Q2Vp+8A/H dXFAKaoGFV1n+Kv035Te6mwYxwEEkKV1WOJX8GUL/MezqGTes5H2vCVF0XvBrRHfOzku Zp4islYpMZcQw0x/5vr9JYfQT8j9TBCToVk/JTBp+QdC4Hh721GOD7vGapoURCSHxb9w AVKw== X-Gm-Message-State: AOAM533JslmdeQ6ClGj4D3QyfVtIO0y6RAofDoCadfqQqK7aewu+hMFg rZerIs6coqRinYkX6e3DGvk= X-Google-Smtp-Source: ABdhPJzVm7MRHTpXf4ZhzddbnhGyfGlLquu07CeyORjwDyd85erInZtVu+WdWELaLPnSXTsxutkJNA== X-Received: by 2002:a05:6000:d0:: with SMTP id q16mr1552936wrx.600.1641403767729; Wed, 05 Jan 2022 09:29:27 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id g6sm43071442wri.67.2022.01.05.09.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 09:29:27 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, spbnick@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH 3/4] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_huion_init Date: Wed, 5 Jan 2022 18:29:14 +0100 Message-Id: <20220105172915.131091-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220105172915.131091-1-jose.exposito89@gmail.com> References: <20220105172915.131091-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The function performs a check on its input parameters, however, the hdev parameter is used before the check. Initialize the stack variables after checking the input parameters to avoid a possible NULL pointer dereference. Fixes: 9614219e9310e ("HID: uclogic: Extract tablet parameter discovery into a module") Addresses-Coverity-ID: 1443804 ("Null pointer dereference") Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 3a83e2c39b4f..4136837e4d15 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -709,9 +709,9 @@ static int uclogic_params_huion_init(struct uclogic_params *params, struct hid_device *hdev) { int rc; - struct usb_device *udev = hid_to_usb_dev(hdev); - struct usb_interface *iface = to_usb_interface(hdev->dev.parent); - __u8 bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; + struct usb_device *udev; + struct usb_interface *iface; + __u8 bInterfaceNumber; bool found; /* The resulting parameters (noop) */ struct uclogic_params p = {0, }; @@ -725,6 +725,10 @@ static int uclogic_params_huion_init(struct uclogic_params *params, goto cleanup; } + udev = hid_to_usb_dev(hdev); + iface = to_usb_interface(hdev->dev.parent); + bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; + /* If it's not a pen interface */ if (bInterfaceNumber != 0) { /* TODO: Consider marking the interface invalid */ From patchwork Wed Jan 5 17:29:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12704555 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 845E7C433EF for ; Wed, 5 Jan 2022 17:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242320AbiAER3h (ORCPT ); Wed, 5 Jan 2022 12:29:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242235AbiAER3b (ORCPT ); Wed, 5 Jan 2022 12:29:31 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4898C061201; Wed, 5 Jan 2022 09:29:30 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id bg19-20020a05600c3c9300b0034565e837b6so2150760wmb.1; Wed, 05 Jan 2022 09:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/KLdWPq2TSaneQFglZodsHn4AgWZAik17MpBqvatAUA=; b=BAn3+iUQ0dqioR3HJwq+czhX93m962svq4IVH6J3qNJRzpSb3YJJUvH08ve/94iTM3 u21cpMA8eel3N0sX3VG0bDUYMTVOk/MVPoR5ySWY2bGn3w/WnLA2/lDlMT9Da9fsvIQR jMoopLNOP95QxBioY4NDmrSF2AN1P0gTbS8iPxnr5h2EQlziWu6w92GEgSFAfmHwZj/v JtYzmlBzv4G6XYcq6qOS37krkR7F9g+XhbaldWX0WCdULvcGkTZPGrBJWsWbGnTD3DVF /8aTd2BSPa7cUnEKTW10ur2u9Wzmt0aLERjzIrdGKGsYA3e+JQTyC7q0efzWP9NHSvEg V7cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/KLdWPq2TSaneQFglZodsHn4AgWZAik17MpBqvatAUA=; b=et0nhsdDjFOOL9vmM4Q5pz03vzT0Lu8gKTDfeunKaI2yKKHS2BfaxHJIwTYh8/X/wE AuwjXZUiZB3k0U5d5DrTEGAWDyqYFovf0X8UM/EHCB/gkPmzLBmeWa3hl7mY4dMckHZu GSFtJucmV+Hemwj3VeShmrFLDEyGeVbgKPrvO92M4C7M16L5uGeNZtbK1drBQaXA3XVv XibCYaJ7a8sDovAhpfMF5yEwRoAQuvOlmjJVy83MzmInqaSUCFEDlCz+HZAlMlMl7UDB g9hEJhJ9rTT1PYiSEso03oTpyJSC2Ch4fyeXjuNrRaP+kcHijjm+YTDOnar3xHUuSM94 NgwQ== X-Gm-Message-State: AOAM533+ZgoWLJD9msEKRrUEaKxcG7jnK9gNerbOEE9UcxXcA+gis2NX g3PreE06NKWa+pekfQbqVPU= X-Google-Smtp-Source: ABdhPJwVS4+SzhHbQTHSejCm1ylGwMd7EpICFV/Iu43Pvr7T7PFRWlZKMdVMlcjFcGInXBKBmTwWVQ== X-Received: by 2002:a05:600c:3589:: with SMTP id p9mr3822613wmq.65.1641403769390; Wed, 05 Jan 2022 09:29:29 -0800 (PST) Received: from localhost.localdomain ([217.113.240.86]) by smtp.gmail.com with ESMTPSA id g6sm43071442wri.67.2022.01.05.09.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 09:29:29 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, spbnick@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH 4/4] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_frame_init_v1_buttonpad Date: Wed, 5 Jan 2022 18:29:15 +0100 Message-Id: <20220105172915.131091-5-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220105172915.131091-1-jose.exposito89@gmail.com> References: <20220105172915.131091-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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: 1443763 ("Null pointer dereference") Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 4136837e4d15..3e70f969fb84 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -452,7 +452,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; @@ -462,6 +462,8 @@ static int uclogic_params_frame_init_v1_buttonpad( goto cleanup; } + usb_dev = hid_to_usb_dev(hdev); + /* * Enable generic button mode */