Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3637289pxb; Mon, 24 Jan 2022 14:06:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3RNGpTkyq0WvoXjUwGRYruqnAY8rXZywToAkOcpLUziwrglxP5hIieOWNnX+1e30ReFnr X-Received: by 2002:a63:2c81:: with SMTP id s123mr8227589pgs.241.1643061998805; Mon, 24 Jan 2022 14:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061998; cv=none; d=google.com; s=arc-20160816; b=r/dXmWJNXOiDnE6irwwnAjIXppjVEHaXyFoo7EtU70DJvFlsokE/8sTI0m6/czs7Db DHo67jE5ZvgFHpEa4RfsuM3LxFDONjEiJOwd6JnJAIrUMabVwPB90BxwOnE7hoQWkt/n ZLhR4Mxhkd80xFe1Ln6lD75hIZxvn0jhJEZAGdvJ2IxLO3sjfvWJoedz0BhaKsrNfZLd 6UAJeHImYMIjuybmiFBpzmGjBvSzUzx/MAIDMlHvqI/7C2iUXcvUp601sIiREdkgYnN2 ufj2IelwVQkcmG32hgoDmGHOx3sTdyYXCNiWVhgl9FvjuLqwAUOzivX04Z7zpcP90rVw WLPw== 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=rDqU7qqCdQBsbh0D6Q30GBmyRt/b3Wew4GvrdpE2tws=; b=JVnuvxp//6NRFMQlbEhlBuCQmrvus/UUV9FdXHNWCpvhaXfsIM0GCJymVvozpdbJOy hdVo0crogIxd3kyEhzt/2YzBb25MI4xUY8434LtHbzcNoz93cjg6XPxfRFDX0vLul6G+ njYwLvLBOBGN2Gwe/jWElJAbp8Fox7R7OzhGNV1bed1cQObEhCzzs7adZ0xM+dGw2UPm mT/gmxHC/patI8kmUqiwW0q79z0FGLae/5krfPiEERuMZ981CPmpSCVc8ywDmQWHAuF5 QxTB9cw9Q163Uytl/1XEg/SqV+wg7baOX4mcopSSA0PGgD8oy7ltdGbYSq+wA3b41nP0 lFwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0d0DaJOj; 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 f4si7435333pgc.600.2022.01.24.14.06.26; Mon, 24 Jan 2022 14:06:38 -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=0d0DaJOj; 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 S1574537AbiAXVto (ORCPT + 99 others); Mon, 24 Jan 2022 16:49:44 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:34150 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388853AbiAXVM7 (ORCPT ); Mon, 24 Jan 2022 16:12:59 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6B8EFB80FA3; Mon, 24 Jan 2022 21:12:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80F82C340EB; Mon, 24 Jan 2022 21:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058772; bh=jbqkzaLPuG7F9MJqasxivM+Wt50FAHFkrTX3lFvAvtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0d0DaJOjH6SnSutFUe4AIw/GpBqYfPgbtv23ZyQrfO45qQSUZGaDZ/futrtcVUG4n ZBZmE5px7QYqrvsZ6bkdWyBT1/C934+eTfPsZL0RE+cgNY4C7EktvK6/FLxJIcXuzl bB9JQaGSYS5ppRnhesXFc57tJGCcGHFPBi7hC750= 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.16 0397/1039] HID: hid-uclogic-params: Invalid parameter check in uclogic_params_frame_init_v1_buttonpad Date: Mon, 24 Jan 2022 19:36:26 +0100 Message-Id: <20220124184138.662439112@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 4136837e4d158..3e70f969fb849 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 */ -- 2.34.1