Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3572632pxb; Mon, 24 Jan 2022 12:32:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxLvnbgSuNhq3co8nXm8Eg4slHHOv330ujVu1aXmJJhJy2OKOyGqdjZpKGCOLCBxP5oXjo X-Received: by 2002:a17:90b:4f44:: with SMTP id pj4mr69492pjb.216.1643056321851; Mon, 24 Jan 2022 12:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056321; cv=none; d=google.com; s=arc-20160816; b=p57HL/A1AWnPWw/PmkYHroEYHCHSCmomk/BRR0YOj6UVO/zE50nxqPBY/yAVWwFmX0 fk/AU5SDSSHfJSATFe6Zxo1TFPG9jwNUwIazQib+YxoM/2fumTuz9a0/m42Rp0XcKgy5 2uNGZj9trI2sV8ZNO9/3pFiJ8smbFNMqP6AU+SUTzAZ7c6luLtIbTe3VQZbln8ojI1jt oM2NVpQOkTyML3jZCrSRtqZzLV/P1Xybw9oUH7ARiWKjj/u2vzxMCEYCLSh5VT4vHd42 HwYRPS9E/1kpL/rBevnnCQ7GNlHKBozFZjLrKZMHhxuB37tkTh8IpUziTf26klsNmZS6 bBDg== 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=t0dZyDqOmgqDavGkT3EVpzD2Lcjz9sUM1dSj8MbU3OI=; b=JBhtHZTeRUCLYeiD3vVbU3tDKmxL0cJkMIErCMrfJQokrcJotOf9toNR51MTHKBZhb L2EjNjXMJ8p05bPLk1nmg2qXCyYpzxXdQPFqJx1PJJilZqETG0zNG4msGeAk7M3+n+WX hYOSLeCIzafMnOqaLjBlVlpahyBI1xcXUZhFQERg2yxcWh8F5S52M94k3F3Zrx69hfFb ncNjRY+nb4U44bHqojYzfSuIIbNc/1k/G32LJtlJ5K/0Tvxws9wuFPYbekEPllaQfwDT I401Yn+4CtjRRbA8+2A1j2tcaZkqy6N839e8hi1PpHc+qw/GRtnUxvSRrLJFoncNg3Nk EcoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jY3AImKH; 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 d21si1472961pfl.97.2022.01.24.12.31.46; Mon, 24 Jan 2022 12:32:01 -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=jY3AImKH; 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 S1354129AbiAXTgE (ORCPT + 99 others); Mon, 24 Jan 2022 14:36:04 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:57134 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352185AbiAXT3t (ORCPT ); Mon, 24 Jan 2022 14:29:49 -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 96CEA6121F; Mon, 24 Jan 2022 19:29:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BC21C340E5; Mon, 24 Jan 2022 19:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052587; bh=/VPIGVCi6Rg+PZ+mSK3jbNzMWjhnDYX74Ty8HuWxxy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jY3AImKH2uiS5AriRHJkGLj7fpjOlpAipEUyvy3lg1ShZ088Bfs/oHqhB0gvXUtLj iQwTZXPjmdghWPxRZWFiG7uJlXtZV+4OXu4YpNovgBniWqdcobesnCP6ZfpHbqUreG 0Vsv7gk9Bwf9NkHatGwV7MN8inru+7y8jDzTlYh8= 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 109/320] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_get_str_desc Date: Mon, 24 Jan 2022 19:41:33 +0100 Message-Id: <20220124183957.423180733@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 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 0afd368115891..1f3ea6c93ef44 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; -- 2.34.1