Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3664018pxb; Mon, 24 Jan 2022 14:48:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgXNe2U6Pi8gt4CJYQwWUmRtcL4A7M1DFn38WRx0Edu0helXvp0o8v9SBTMKfn3nK92a+b X-Received: by 2002:a17:90a:588f:: with SMTP id j15mr514885pji.242.1643064512541; Mon, 24 Jan 2022 14:48:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064512; cv=none; d=google.com; s=arc-20160816; b=biSVoCho39UoKwoNhjQoCTyinaucoM/ygGX4Fo/fFNXIbr4b47cduacQ0AFpm2iXcr tYmdkhvbX7rdOgmKhHfRvCsjaF039HyBJCIyH77nSj6MdavD92fjMEvnfyaygH6kqgYn LyxIq5IXGBvCUks0Detez+hodxnT37PzjjLTY7ZXoRgb2F48fYnz/GfyZoCeVSdGsB/p ru79o++4/HPS1+70N1jSjK4b5NZjjzZ6FyRx3RQXYIClT5mjMN7MIaiVtcjB3A3KmdDJ Af5JDc0H48ivr6uAq7NQQUUBW8QXW5jZjsYS1o+zjYZFwq/pCFfXEyH6Dmgy32K2/m5q sH4Q== 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=5IlhQR8M1FIWjQPIiky66WCaBizJcZ+zGFuuNccAwxk=; b=JfS/BiFIYL63dO4BK0800S49rDLEBtIsFqy1HkA8heQOc2hEWiRxgi8534cGkqFtxp Ya/sYWxVMiEO/Jtq7/V2MBJAC2XCBThKmUHr+fmsFMYyPoGGC6+IbGcCQ4e/SoscCTnA wGN+wBdu4MOEeqcowYK5Jh9IBW7eyO6noDurQEYaA2PHdFCZJFewFtpQopSpSLpk8MoE D58dbgBx9QVEnT0tboHjpnfzkAn/TiSkWLr7MkCN9y0oBp2HiGT+ak+AiQJMj0JiG3UA CjPgyNUp9pzKrDnMrkEtTFWtlTZ0MnqHfD4g8/A8321YvWC5WUj7hLbepNbqA5bw6nPx kFEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mhPyQjKW; 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 p1si7676249pls.193.2022.01.24.14.48.20; Mon, 24 Jan 2022 14:48:32 -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=mhPyQjKW; 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 S1838369AbiAXWq1 (ORCPT + 99 others); Mon, 24 Jan 2022 17:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457338AbiAXVlb (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 637FFC07E31B; Mon, 24 Jan 2022 12:27:57 -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 016BE61506; Mon, 24 Jan 2022 20:27:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC9B5C340E5; Mon, 24 Jan 2022 20:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056076; bh=VCWqXz36B9QGd4a08A2VpVo1EMBQYp8qx7VMIPbcbn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhPyQjKWewB9me2T6KanM1Io+GhjxGMTECvp+3HaiduWjJLNyi/FKiDZvTrvBbG31 LASFYyk2bzV/vm/iTAqAnZrk/PM+NWXKk1eGkyrKJmy95liKToBwR6ENS8qJkGHklt B/T7KpiOE4A4zPA60NbSd9eRnpc7pHRsxTOmxvIU= 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 329/846] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_get_str_desc Date: Mon, 24 Jan 2022 19:37:26 +0100 Message-Id: <20220124184112.258380417@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 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 Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- 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 3c10b858cf74c..3a83e2c39b4fb 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; -- 2.34.1