Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp47429pxk; Tue, 15 Sep 2020 17:23:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4yA2K1c087Tf1iclo/aomeoKuYDdqxyPShCS6rHW+7n7gpceQf9CBIRKdjk3DXdo2W74f X-Received: by 2002:a17:906:b1d7:: with SMTP id bv23mr21814238ejb.464.1600215789545; Tue, 15 Sep 2020 17:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600215789; cv=none; d=google.com; s=arc-20160816; b=sdF8+gZKs9K2IhKp9OAL7e8Vyv+l1BmAhqI6NRiCX7WFBvt3zTxXIRO1ytrz/6GWQT m5gqOrmxko2Vbx9Ddd796f87YmLW35Jd+Xlyb627L9+bBqFmXjLAhHgX0o6DCgJoXx9C ZcvT+FvdU7Zp+KYC0quZDHplEdTou8Qlc+o27j32ShfiKdjfbqw3D0oRW5WP6Iu6Jn7L epWJc70dCuSwDTzx6tP7Kl9T+NAbMYBKb8qePXWwviPHsaTavZigzr0+sqtU4lmn6U4u pqEx/2tjQjFv2hjqCX0j5mDqiTh/uUjmh3zX6jFHdRNFWmNIJ32z/0YdGWBtc414eINj YyGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=r9DcM6CNfvtNeisNsuaNTBCxT2g1tANre1WyENuqBWc=; b=oO6gB+FFPBLABcOGpJgwavKwjYc5/zcaV1H/Q1sbRq0KTZjiQwAMgKLfShvVChg+bZ Trb+hex/c3PkDuMb5brtEiU6vXIkXxmFEzFfnNJrkmK4aRFzCIS350F/H0UeJ3XQQ6kZ KM2lMeguJrb/xjBJxTNDh0f2hoQywEFHDhxaJuGd/F2gMcSlwD3HqPnjv4V7sXeMViS0 XiqblzpKw8IBY1fvSA0H7qu/28f2s4E6/iyuXhsTyLmBmCBJq7ozrtN8Y8l1a/STbMGL Kk1k0NPbb4w/fyOaEtP0TCr4A3MBBq+QYCO9P6bNkpua2lS1ao4jbG1EiOmBOh42knco kyKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Bd4+1E08; 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=fail (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 gr23si8488540ejb.586.2020.09.15.17.22.47; Tue, 15 Sep 2020 17:23:09 -0700 (PDT) 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=@kernel.org header.s=default header.b=Bd4+1E08; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbgIPAWK (ORCPT + 99 others); Tue, 15 Sep 2020 20:22:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726873AbgIOOVf (ORCPT ); Tue, 15 Sep 2020 10:21:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F4CD22265; Tue, 15 Sep 2020 14:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179438; bh=4ABVsmh5jI5NnXO2oNl8UNhINhHcy7IXqkNT+Q5jG1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bd4+1E08akzBnpRyk/mBXSpxWFR5peJ+cnKlQVKQ9EYEL1vp1q1nSRwGknLyFbnO3 HQYK0X8uUmDO0x2Ns20b38lhyNglfxjgPu134au4sjZPvrj4Lm9JalYMpGV1yLYmah y7jBsikGFOqGAEph15y9UJnuZdrDHSl4tWgR9Mlc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Jiri Kosina , Sasha Levin Subject: [PATCH 4.19 32/78] HID: elan: Fix memleak in elan_input_configured Date: Tue, 15 Sep 2020 16:12:57 +0200 Message-Id: <20200915140635.193813299@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit b7429ea53d6c0936a0f10a5d64164f0aea440143 ] When input_mt_init_slots() fails, input should be freed to prevent memleak. When input_register_device() fails, we should call input_mt_destroy_slots() to free memory allocated by input_mt_init_slots(). Signed-off-by: Dinghao Liu Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-elan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-elan.c b/drivers/hid/hid-elan.c index 07e26c3567eb9..6346282e0ff05 100644 --- a/drivers/hid/hid-elan.c +++ b/drivers/hid/hid-elan.c @@ -192,6 +192,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi) ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER); if (ret) { hid_err(hdev, "Failed to init elan MT slots: %d\n", ret); + input_free_device(input); return ret; } @@ -202,6 +203,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi) if (ret) { hid_err(hdev, "Failed to register elan input device: %d\n", ret); + input_mt_destroy_slots(input); input_free_device(input); return ret; } -- 2.25.1