From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81366C43215 for ; Fri, 22 Nov 2019 19:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 556512075E for ; Fri, 22 Nov 2019 19:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574452211; bh=fzyZL7VEQ5qaDDzeEpiTbbh7tVbsMNlgyyDqcnqWLYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sfDp3mg9bebBDdkxoblpTqUfHhBHLqkV/SOT7rQny5p78S1+FZ5Prhzphj7chN7we uVxZl7lbiwTpq9tzmi4taS7kFTXfDIhG6o254Q/WX/86tAitQ/01e3KM7ppCzPhKuV BIw23kDsURk/YJpy4oLR7PmzSKJwV4bssLlHJC9M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727754AbfKVTuK (ORCPT ); Fri, 22 Nov 2019 14:50:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:50586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727718AbfKVTuF (ORCPT ); Fri, 22 Nov 2019 14:50:05 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4C0C2084B; Fri, 22 Nov 2019 19:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574452205; bh=fzyZL7VEQ5qaDDzeEpiTbbh7tVbsMNlgyyDqcnqWLYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jzZK8EqICI+P8Zn7mO0ycLzEZZb/8BisrpgD0eFjKFFfPc5UvgPoMaka2f7UawUrM Lj7TxrFBYWFze76Y4CRVHdGYaHwH4S+ZtfsLakcqQ8a02Y/5RbJbt/My0Q3Fq5xFsx jVp87eX1rps5C3322QsoGIMWEp4ccoEZ/zEoOr8s= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pan Bian , Dmitry Torokhov , Sasha Levin , linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 06/13] Input: cyttsp4_core - fix use after free bug Date: Fri, 22 Nov 2019 14:49:51 -0500 Message-Id: <20191122194958.24926-6-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122194958.24926-1-sashal@kernel.org> References: <20191122194958.24926-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pan Bian [ Upstream commit 79aae6acbef16f720a7949f8fc6ac69816c79d62 ] The device md->input is used after it is released. Setting the device data to NULL is unnecessary as the device is never used again. Instead, md->input should be assigned NULL to avoid accessing the freed memory accidently. Besides, checking md->si against NULL is superfluous as it points to a variable address, which cannot be NULL. Signed-off-by: Pan Bian Link: https://lore.kernel.org/r/1572936379-6423-1-git-send-email-bianpan2016@163.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/touchscreen/cyttsp4_core.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 44deca88c5797..c1c29d7487bf3 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -1972,11 +1972,6 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd) /* get sysinfo */ md->si = &cd->sysinfo; - if (!md->si) { - dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n", - __func__, md->si); - goto error_get_sysinfo; - } rc = cyttsp4_setup_input_device(cd); if (rc) @@ -1986,8 +1981,6 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd) error_init_input: input_free_device(md->input); -error_get_sysinfo: - input_set_drvdata(md->input, NULL); error_alloc_failed: dev_err(dev, "%s failed.\n", __func__); return rc; -- 2.20.1