Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3771326pxv; Mon, 19 Jul 2021 08:22:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRE8dtb5grf1hsYl31MNr6Gqz2eERdLWqHRWNFTA6U7nmaHGC4i4JgWadgqMEIsqll7e7m X-Received: by 2002:a17:906:4ad2:: with SMTP id u18mr27305956ejt.549.1626708142718; Mon, 19 Jul 2021 08:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708142; cv=none; d=google.com; s=arc-20160816; b=xVB8Cz4LDwqqneCJj4PDkjuKDeZ29Sh/yy83wQ9zwovTIr5ZuFLZ3ccdgfjumyDvD1 IUJQ8aV3WM9GyXjeQlaWZZYlJviF3nWCCZThMSmCa74OPMnVTXd+Tn1OWPX6gJFv9aA0 NlJef7xKupbFDQosRvyELX2HoEqp8hLuQIbaLF+XAxU4/koTNQHKeaIqcx1VeCE/7XmC zPhPQtmb2d+lMxqbp8PDq1RVC4eTrfz1T61mV7hLBXdP0LkdFFBWCFLJh1Ia4+OmXGwQ PnKSQAr4i1ft8lYWOBY/M2834duFZ/yndJUZv5nPsVlh3C//zlMKB6i1Eg8vHAHyq9b/ +hKg== 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=8Wni6bKFHfQC8cdj20PPL1gHOdD02V0d3viEeIB89nY=; b=B7iQ4H9+bS94M7yskU1oLl/y23k3mNnYQ+g4+KXe4jynuFbCjOlAwgpcZUHJDAUcFn I0umtTEZDCHW60UgLndkBH2Y+kgP1LBbGqknTC87L04PKcxLjtaM6ayRv8TiHhFOxeGL mi0wiBxoqza131cMnn7m/JzQAbO9r3SbOMhSnNXK6JTpywHQcdSQ1LSm1RIMCLFIGiaJ i9xOk0vg8gyUGvbeDizEB0H3vO4j+wXCEbE9pCIW/d32F7jAeBa5A1s9zPS2fYyssKG/ xJDBaXKm/CXX09k1rm2MP8J/hQqs534rd8z4vOgdEoaXaJfzBkMJUN0zZp6jyWZY9f5r C7cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fd6V93Sj; 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=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 d9si16228172edx.50.2021.07.19.08.22.00; Mon, 19 Jul 2021 08:22:22 -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=@linuxfoundation.org header.s=korg header.b=fd6V93Sj; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242977AbhGSOkX (ORCPT + 99 others); Mon, 19 Jul 2021 10:40:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245107AbhGSOaT (ORCPT ); Mon, 19 Jul 2021 10:30:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BECDA60720; Mon, 19 Jul 2021 15:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707458; bh=nzdydNYmLflCaFutndl1RJtdrTqtelCnjdq+dPZ1GI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fd6V93SjWoExGtRJOGbqmpYLYyzicvBjrbmB2Uku4euEG3i0Rp/vJSVqq+09ZTEPq t/Uq3jjrqWbhwvyB+jI7g0kYZl2MVeNcFOT0sqJPVU1DHtTuxVNsS46rWJ1NU0Ka2C eJGzhYERebq4by+qjr/J6WPxavozmnPomxvtq8y0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Samuel Iglesias Gonsalvez , Lv Yunlong Subject: [PATCH 4.9 171/245] ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe Date: Mon, 19 Jul 2021 16:51:53 +0200 Message-Id: <20210719144945.929352762@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Yunlong commit 9272e5d0028d45a3b45b58c9255e6e0df53f7ad9 upstream. 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") Cc: stable Acked-by: Samuel Iglesias Gonsalvez Signed-off-by: Lv Yunlong Link: https://lore.kernel.org/r/20210524093205.8333-1-lyl2019@mail.ustc.edu.cn Signed-off-by: Greg Kroah-Hartman --- drivers/ipack/carriers/tpci200.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c @@ -591,8 +591,11 @@ static int tpci200_pci_probe(struct pci_ 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: