Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3738971pxy; Mon, 26 Apr 2021 08:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh4Jlb7UnU+f4pK+eood9BgvK+trw4pGkvMmAac6lr8IJ3tybtsgZnONpYQCjyTWXGCzms X-Received: by 2002:a17:906:3018:: with SMTP id 24mr19265054ejz.186.1619451526987; Mon, 26 Apr 2021 08:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619451526; cv=none; d=google.com; s=arc-20160816; b=OutSLFyvp0r2+fTGqBkH9IZKj3f3mTjOlCvqWhiSwGGNvOjvXfjJYFzfz+1L9iFs9g IumimyL0Ty7Nb67Pc7Fr9I/KTCv2SwEIZauS1wK/DWJNt+MjDwZCreMoIx7QHCayqCrv tOh7LgWndNF5kdg9gpxF1EJPF2O/Em/OaOcJDrg5fx//e9CcLF3uLFkguddgI1a2RzV2 B5RF6/mkDANRW5Yk7tGk+dVb96yn1afLUKkgEmobPGmBnbBmwO+lsokaBtwPKEjZDaT/ hMyprrTp31z4oBEzptFxSGbs5PO0t413ywXC2zSX6jMFp5AWsm4/snDCyPwoTKVcTW6W CiWA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8QYGljFb5EAOcfFXhgSb6txhlNcsv6mgPjDeDUMQExc=; b=XR31KWKOx1IthRZ6LWvKuVdTpjRgL0OEtqlamc6XLHgfhQieqa46DGeBEgAb+5Fymu A11QCYnou5CbudifWHclX4qTifidry/03P5z31jKSRSFJsF15SD7AhvRRJMK85vafMWQ etHXmsUDlxI11DkaMVebc+XFzxQBqYswNAfX09ElhTUpkBomm9oB1xf22BO40WGFVmJs RqY6zEmfWj1TwoD4Fb7mftjJYD0wo+rQTfZo4Vi2mVOxaHOlVdDyoFAqv/9ub9VJDrEd htVIlKvpclZZ3yZNa9EbmzgUvap7WCVnp6I3AHkVHu/QY/wraqIuRO+KVUelkB5+BgJa wGeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=fPhnji76; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss2si14040019ejb.370.2021.04.26.08.38.22; Mon, 26 Apr 2021 08:38:46 -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=@mail.ustc.edu.cn header.s=dkim header.b=fPhnji76; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234084AbhDZPhE (ORCPT + 99 others); Mon, 26 Apr 2021 11:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233674AbhDZPhC (ORCPT ); Mon, 26 Apr 2021 11:37:02 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 12A1CC06175F for ; Mon, 26 Apr 2021 08:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:From:To:Cc:Subject:Date: Message-Id:MIME-Version:Content-Transfer-Encoding; bh=8QYGljFb5E AOcfFXhgSb6txhlNcsv6mgPjDeDUMQExc=; b=fPhnji76bGqvSDwYkVWRsB9sH/ MHR7E9iQgO02JHFHQrmDfz/xg/ddiRG62DFWu92MeDvqDg/5l7GiwXfBdk8hW9YX FCXNzCIWlq13F7IOF937PeFjx/rziwsHDTD0KAi4ltJHE5LEuAGAcdW6OxdCnCsy fkvksAmuVzrN2N494= Received: from ubuntu.localdomain (unknown [202.38.69.14]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygB3fzfW3YZgnMRLAA--.6467S4; Mon, 26 Apr 2021 23:35:50 +0800 (CST) From: Lv Yunlong To: siglesias@igalia.com, jens.taprogge@taprogge.org, gregkh@linuxfoundation.org Cc: industrypack-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Lv Yunlong Subject: [PATCH] Staging:ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe Date: Mon, 26 Apr 2021 08:35:47 -0700 Message-Id: <20210426153547.9058-1-lyl2019@mail.ustc.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LkAmygB3fzfW3YZgnMRLAA--.6467S4 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFyDWw48ur4fKryfGw4rZrb_yoW8GrWUpF 45A345Gr9xXa4rCF4IvFWDZF15Cw48t3sYk3yIk3y3ZFs3Wr1jkFs3AFyUXF48tw4rGF1x XF1kt34UXF4UJwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvG14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Gr0_Cr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IE rcIFxwCY02Avz4vE14v_XrWl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr 1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE 14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7 IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjfUb_M3UUUUU X-CM-SenderInfo: ho1ojiyrz6zt1loo32lwfovvfxof0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the out_err_bus_register error branch of tpci200_pci_probe, tpci200->info->cfg_regs is freed by tpci200_uninstall()-> tpci200_unregister()->pci_iounmap(..,tpci200->info->cfg_regs) in the first time. But later, iounmap() is called to free tpci200->info->cfg_regs again. My patch sets tpci200->info->cfg_regs to NULL after tpci200_uninstall() to avoid the double free. Fixes: cea2f7cdff2af ("Staging: ipack/bridges/tpci200: Use the TPCI200 in big endian mode") Signed-off-by: Lv Yunlong --- drivers/ipack/carriers/tpci200.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c index ec71063fff76..e1822e87ec3d 100644 --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c @@ -596,8 +596,11 @@ static int tpci200_pci_probe(struct pci_dev *pdev, out_err_bus_register: tpci200_uninstall(tpci200); + /* tpci200->info->cfg_regs is unmapped in tpci200_uninstall */ + tpci200->info->cfg_regs = NULL; out_err_install: - iounmap(tpci200->info->cfg_regs); + if (tpci200->info->cfg_regs) + iounmap(tpci200->info->cfg_regs); out_err_ioremap: pci_release_region(pdev, TPCI200_CFG_MEM_BAR); out_err_pci_request: -- 2.25.1