Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp451336iog; Mon, 13 Jun 2022 06:14:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5WtiNSSMLFFCsqmflCPVYZ6nqahMbVfTSEWPEfKTCX9cmlpioqrTlv3DabSAnDlR8ITd1 X-Received: by 2002:a65:5207:0:b0:3fb:c00f:f6e4 with SMTP id o7-20020a655207000000b003fbc00ff6e4mr51255923pgp.415.1655125619194; Mon, 13 Jun 2022 06:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125619; cv=none; d=google.com; s=arc-20160816; b=wn0dPzeVykQ3HRfcOyDR9I6zEVxphcDM2DtPmZGIWua5b6MYFScsJinAqLhtmeZXFF jEd37OC9MblO4IU7Rfafuh67b8d1KDbhegEmKQLSpJ96Jj3xsQp6H1RJjk8lp0tRVT2r 8tIsQAAGRo/LBhmc2djInp+7hv7FYRxy5RZzv5vBIP2zyj6IKKJIynoeexUKWPTj19Ig yxAWQTUt613WAfuUljU2klY58QHcqwcJ9KhajMSXsMGBZuzT8jENmTWaCGReupgDmBn3 8wEMisxOE01HjW1/VfNiCglkCpO3jILkgdROH822IP3PblPlsI0QC2VkWd1LPsk25Dh9 U9ug== 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=WwUtF4V4vCTQX0OYmhEShXl+cNd7qhY4asMAFltecO8=; b=lxVNWg2H8ZI0CW+1ag81zuXfpcjFf1KOc1GIadhSWrZx7nrb0PUWEaAyWADk4tN/6B xO1Wn4faTzcMChdRnYLzNDXCrfbAKXNxptVclqEikM1CXUdTqHoucymslcDRdG4FCpkP osJNjIOGYQo5hDlsSPptc/Mw2vJPxkJx0M+0lwHOloKzi1wNc3dHUniY+8QaK6FEnHp8 a4f/8jY2YdYPyOKVd+PgpbZzqcQREIsV5SY/29jjn4hpjXO1rNzEGllmZGbvFI1d5vLD c5LdvA29erkxOWdf4kBFX5aWV1GMyjVmZ2uCDrd9eWNiL6PDrkBjKfc8uqRYm5lnMTxZ busA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xi6nIHw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a056a000b8200b00518929bce96si10741155pfj.213.2022.06.13.06.06.44; Mon, 13 Jun 2022 06:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xi6nIHw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1352276AbiFMLLa (ORCPT + 99 others); Mon, 13 Jun 2022 07:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352008AbiFMLJO (ORCPT ); Mon, 13 Jun 2022 07:09:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540E6338B2; Mon, 13 Jun 2022 03:35:21 -0700 (PDT) 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 B2450B80EAA; Mon, 13 Jun 2022 10:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 128BAC34114; Mon, 13 Jun 2022 10:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116511; bh=T4cvfR4WHCduCcFXKo/nqm80YevLxO60ECFJam+FNdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xi6nIHw2pjyhUFJVF3PKz+DAgn2OtmFdrrCd9H80n25dT93V3KWCDIef8sO98vYJp YNpbfjPA6lsx1X4m9RL98VCtebA0QV6/gk1AhOCuXpM2KCVHh/hSSioTQJR30B1jdh 9Va5InyHst9IxmnO4/D/qXoJXMirCrm8ujxvsIyc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Benjamin Tissoires , Jiri Kosina , Sasha Levin Subject: [PATCH 5.4 099/411] HID: elan: Fix potential double free in elan_input_configured Date: Mon, 13 Jun 2022 12:06:12 +0200 Message-Id: <20220613094931.649108885@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin [ Upstream commit 1af20714fedad238362571620be0bd690ded05b6 ] 'input' is a managed resource allocated with devm_input_allocate_device(), so there is no need to call input_free_device() explicitly or there will be a double free. According to the doc of devm_input_allocate_device(): * Managed input devices do not need to be explicitly unregistered or * freed as it will be done automatically when owner device unbinds from * its driver (or binding fails). Fixes: b7429ea53d6c ("HID: elan: Fix memleak in elan_input_configured") Fixes: 9a6a4193d65b ("HID: Add driver for USB ELAN Touchpad") Signed-off-by: Miaoqian Lin Acked-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-elan.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/hid/hid-elan.c b/drivers/hid/hid-elan.c index 0e8f424025fe..838673303f77 100644 --- a/drivers/hid/hid-elan.c +++ b/drivers/hid/hid-elan.c @@ -188,7 +188,6 @@ 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; } @@ -200,7 +199,6 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi) hid_err(hdev, "Failed to register elan input device: %d\n", ret); input_mt_destroy_slots(input); - input_free_device(input); return ret; } -- 2.35.1