Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3573324pxb; Mon, 24 Jan 2022 12:32:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJycFNvs6YX2j+3+anhs9begGF/mkDCXChK1YcHizv8NLj4GW4z7LNbzQCS9+ShiG02gClD3 X-Received: by 2002:a17:90b:4d05:: with SMTP id mw5mr68323pjb.206.1643056278632; Mon, 24 Jan 2022 12:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056278; cv=none; d=google.com; s=arc-20160816; b=ntXCXgqSbV3i2aJhjv0J2uEvrSW03KXzHVCcFMBa6JscaSRhU8ouQ7uW/DkDSaDWbo IvheKzrs//hrxLcZsIv19TnCbAzF02sCrSNVcwbWCbfJfnmoguXyrgqukBG7LuqSj0rM ImIBZzfNuf32urjtYH7EHkEU4isfHkmKbfVA3n8mhrrjmtT0J3Ag7Tkcx05Nhjq1Fo0D tB4FvywHGOLunYe97upLhJvcJsLaD3xzL/LPDoB5NNEtv3n4Oe+QQa0ysTu5O/6zIvzN crBXxrPgY6IPdqqptlGeh7jOOtQKPlB2NcbmdV8GOzYIFRDiMfMDn/7eCgxo/04A+iCK Obnw== 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=EB4XCJb/uKe0Patv1GtYyLogF0lgR7C0td8dvZ+1q7w=; b=cgQTDNZhFO9QkhOVcoz0dyVsj5HF5n43K3pZ/oGUPjm/EfPKkU0uG5pE1kdIgp+tWy fv6ScxBsfEfUtZ2xx3XEsWaBgiicPFzRCySDjGDVE3WkbO4lDiS/bHotN/+dhAKna5TW LCbFOJk+GyJvVlt44hz9FmwVWze2P/tq9P8LJ4pYBRADMWDiGsFPsLt8mh7l9wU5bVTt SJqR1aG0Hw4FI8DynGD6jI2LTNqlOq2dJOP3pMCpJdtpHtdmwt+bUNEuLWsFWxmvW5E/ 9FlhtaRWDoBx4KaTpi4EAonyf5LXiyBQaUeIT9Tt2Zdqj0KgPRi5t7i3jHVqQD2d7I8a TKkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="iC9z/snK"; 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 g193si530990pgc.397.2022.01.24.12.31.05; Mon, 24 Jan 2022 12:31:18 -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="iC9z/snK"; 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 S1354152AbiAXTgH (ORCPT + 99 others); Mon, 24 Jan 2022 14:36:07 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:57208 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352209AbiAXT3x (ORCPT ); Mon, 24 Jan 2022 14:29:53 -0500 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 5F3E1614BB; Mon, 24 Jan 2022 19:29:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2019DC340E7; Mon, 24 Jan 2022 19:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052592; bh=y4gopLlU9cEaDX+IdBrDk0YyHq4orGkuszg4cJuHrPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iC9z/snKrDgtDIrH7t7hUxIPeIgV2U8ahUVCP89JcnAEKNYngE382iSZNQdH64D3i j7Zjp0NYoXi97dBCbc383JAMYnqsXJ6+NfJuisNL0rxLIwgrWUhWPGrwdVs2r7L5RU SYxmRe6YpJUijhGlpcVc6OPR8Rp42gtlXqDc89NA= 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.4 111/320] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_frame_init_v1_buttonpad Date: Mon, 24 Jan 2022 19:41:35 +0100 Message-Id: <20220124183957.494825008@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 aa320fdbbbb482c19100f51461bd0069753ce3d7 ] 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 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 0fdac91c5f510..191aba9f6b497 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -451,7 +451,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; @@ -461,6 +461,8 @@ static int uclogic_params_frame_init_v1_buttonpad( goto cleanup; } + usb_dev = hid_to_usb_dev(hdev); + /* * Enable generic button mode */ -- 2.34.1