Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3660659pxb; Mon, 24 Jan 2022 14:43:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyu7lI8RckvIu2a3TXazWeHrcnj/bZ3IqUxlS0qrlNndlk6eyTqWi2kB0kDchgWbPP2kdtA X-Received: by 2002:a17:902:b687:b0:149:90e2:8687 with SMTP id c7-20020a170902b68700b0014990e28687mr16366138pls.131.1643064182215; Mon, 24 Jan 2022 14:43:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064182; cv=none; d=google.com; s=arc-20160816; b=gtW+Tw8a1eT1iZmiVx4IGbusVLE3n7JyGszqviGq5dcGnGzjguMQUQgs8Tzmwwuqqb FJaizFp+ijiMz7uR4gn6Y3B0k/qlmWFpIky/URJh9MHnSxfWNdpKPXI6nWr/rc9AQAsP jHURp9sh5KICBdAmv93crBINeLfrWudF483oeWrR7WInn/3H0PiPagIN1Qil4zulz9Ls W2R5+nBp0xWzlSRGKx4F1+rAkCfmVGemDtkisqm3ZA2B8MSFsAaeEyEB80vd3vBS9s02 45on9A7eFkGwDvf2MBZZiZC8j4hc0c8whSGb2jGQnIZ2Q1CVcyzpE/GAY88rhz1djjne w4eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pH5Rlt9hqwn6Wl2EDsrJ8TcaNhtPaLvL6Yv+mQvvgfI=; b=n5F1+64J2dN4GDxf+Rq0CR3uJd1X+TQLjL31iHjNV/cgR9akaTP/JCMw1/yfRZtKtY EcjTST/45lwKjD/qM0Inv/Csly/a9sDeJ+NCk36aVFwD0osQ7NhYdc6/Xz9yGnkXgt4m V2zEIpJnpKoVoovTuYArT50JSBW3FzfWaFvzEWG9wZV7+SyVqoZqEFDyRyxJR+nB9XKf 9qdWDRz7GeVNUpwMcOeTgsfRIdjjERnZlG262GK1CytaruzE6NUVke3ccm0/JyJxPRWB kY8tnHsA39MMd8rDSmIY29vNKjiJ09ybxlc9mXKkVT1FCBsT1fqmeuTAeyZYv9HogA6l 5t1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YiAHZNBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 123si16524501pgb.7.2022.01.24.14.42.50; Mon, 24 Jan 2022 14:43:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YiAHZNBM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1836595AbiAXWkK (ORCPT + 99 others); Mon, 24 Jan 2022 17:40:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457337AbiAXVlb (ORCPT ); Mon, 24 Jan 2022 16:41:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33F85C0419D2; Mon, 24 Jan 2022 12:28:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C841961506; Mon, 24 Jan 2022 20:27:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9C1DC340E5; Mon, 24 Jan 2022 20:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056079; bh=7n7G5SKrA1dBR0fD9xutzkUVLmfgbdkxbUUx2QGunBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YiAHZNBMqMDHLhxM6KBbceHJL+74leDr10svYpN0vgbU4q9qMsyTcYYKc3fSGEinE pHRsE/AEHNDE80KrxwbWq+dg7fe3VCgp8KeJijsnaIel1uPYqJ3D0m6zmpavm46oxK b0fvzh6AxsdV17AobHzx8nQmFWhgTZFUTO3gwH/Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Jiri Kosina , Sasha Levin Subject: [PATCH 5.15 330/846] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_huion_init Date: Mon, 24 Jan 2022 19:37:27 +0100 Message-Id: <20220124184112.289601276@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: José Expósito [ Upstream commit ff6b548afe4d9d1ff3a0f6ef79e8cbca25d8f905 ] 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 Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- 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 3a83e2c39b4fb..4136837e4d158 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 */ -- 2.34.1