From patchwork Thu Apr 18 01:58:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pan Bian X-Patchwork-Id: 10906437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F08B1515 for ; Thu, 18 Apr 2019 02:14:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 701E426490 for ; Thu, 18 Apr 2019 02:14:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 615BC284BD; Thu, 18 Apr 2019 02:14:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E045626490 for ; Thu, 18 Apr 2019 02:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730258AbfDRCOs (ORCPT ); Wed, 17 Apr 2019 22:14:48 -0400 Received: from m50-134.163.com ([123.125.50.134]:42223 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729189AbfDRCOs (ORCPT ); Wed, 17 Apr 2019 22:14:48 -0400 X-Greylist: delayed 914 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Apr 2019 22:14:47 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=tH6E7FoBnszZj55i5i 9lHvJ8Y0KxCuAXuPMwnApoTE0=; b=BTif/b8wk1XVp4we6YgGyE/HTPjVOoH3IT BXyKZI4htL4DNVCBnwJ9hKrisLo2/ylW0sEsVdNT4+UhHgIHe/gAQsIy+j1BdctI 1HiDVZ9E0BuwZcSL71+M6NyFTsw1xJJcv7JVxXZCrYPPfKYZ9IuohSKKPo80aVws H1lMezBZE= Received: from bp.localdomain (unknown [218.106.182.174]) by smtp4 (Coremail) with SMTP id DtGowABXsVLM2bdca969AA--.0S3; Thu, 18 Apr 2019 09:59:20 +0800 (CST) From: Pan Bian To: Dmitry Torokhov Cc: Wei Yongjun , Nick Dyer , Nick Desaulniers , Kees Cook , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: Input: synaptics-rmi4: fix possible double free Date: Thu, 18 Apr 2019 09:58:35 +0800 Message-Id: <1555552715-34820-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: DtGowABXsVLM2bdca969AA--.0S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Gw47Ar45CrW7ZF4DXF1xGrg_yoWkGFXE9r WfJ3s7Xw4jkry8Wry7A39xZry0k3s0qFWfCr1Fq3s5Kr17Z3ykuwnrAr4qyr1DWw17A3Z0 9Fy5Wr1kAw47WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjlfO3UUUUU== X-Originating-IP: [218.106.182.174] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQB+aclSIaGwqEQAAsU Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The RMI4 function structure has been released in rmi_register_function if error occurs. However, it will be released again in the function rmi_create_function, which may result in a double-free bug. Signed-off-by: Pan Bian --- drivers/input/rmi4/rmi_driver.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index fc3ab93..7fb358f 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -860,7 +860,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev, error = rmi_register_function(fn); if (error) - goto err_put_fn; + return error; if (pdt->function_number == 0x01) data->f01_container = fn; @@ -870,10 +870,6 @@ static int rmi_create_function(struct rmi_device *rmi_dev, list_add_tail(&fn->node, &data->function_list); return RMI_SCAN_CONTINUE; - -err_put_fn: - put_device(&fn->dev); - return error; } void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake)