Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp623175pxv; Thu, 15 Jul 2021 11:48:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZzETuETcRuX5Y4ndcEhRB5vyYbzs6UoTT9LGqkn20xr2qeCqeYc8JbD5rIoXT6TPPVFAI X-Received: by 2002:a92:dc4f:: with SMTP id x15mr3638174ilq.64.1626374891531; Thu, 15 Jul 2021 11:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626374891; cv=none; d=google.com; s=arc-20160816; b=ERlZ9aLxwhTDcZtetSNI+5w9bPAgr+BQm7IrJWZJn/Zx93flSchRVDB9DRpDawg+Ag 0EgkYvkWnarUDtX/LJgQzFbLqipgkQZH/BNX3iqXWTOORdQAwYuYRyOLLQZt7MadqExx oAdCKZ/xdCr0TxUiqPRQwgvLxLC/J+ZF/ho92xwoBXMUrcgjHlKUtLsPg5XN2jCYx2It kAE7ZLgqEy32KLViCYRPyNg6rDdz3/8XCYeZPpLoh5gvoZMvxRncxyW0xHDI7IkT1GUq HsEmnoO7RdzeNQpl2pFSneCoZ9OyhUTb3QkSlj5uwjWXotYPb1zwHb/iDiW3w/ggJCSH YFog== 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=olR1Oy752pC9jgJNbgwZCw6vMigGg28lyoR8wiZxYqo=; b=V+u3m7fhdW/B6ge6oVQ+FGpm3bwqNW4QfzuQYKeDnK1whcB3mcat4X5U4G7yfSYaqK tEX2pOrDfRnEcWhyCRsb3ZRV7rGex7lfntrHe4zRTh++ICDAFHPOGoGU70PBl7ITzIxc H/KF5rPzF5PMNw0N9afTw1KsZ1228H4x0a/+nQo8ov7sU9BGEDluFfziJP3blM7ezON3 wrav4jQ9tx9Ww/3EHb5HWWBwsQLHy9YFBzZ3IVadxXsrGBV71nR9Q2mrQpkKUN84j/OQ U/5j8sM34eV7Zoc8vwsdh+outW1yu4zP6zWyOfDq4yO1cfQ5T5c0qGtxgyVbG8TkkUDe GJzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Y9KuoKB/"; 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 a16si7023659ilb.149.2021.07.15.11.47.59; Thu, 15 Jul 2021 11:48:11 -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="Y9KuoKB/"; 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 S240345AbhGOSuV (ORCPT + 99 others); Thu, 15 Jul 2021 14:50:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238940AbhGOSrs (ORCPT ); Thu, 15 Jul 2021 14:47:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C9E861158; Thu, 15 Jul 2021 18:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374693; bh=oDj4QzskaiCbEtmnzszlg04IE4Xh1gAq207OnqONIEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9KuoKB/4oR5/mXDxd9sJtlvYwbNX5MC0JESnYEbrGUMA+XpA2bmVGWfav9oCS9ZS DjTcH8uEeJ58gXpZzOHti9vsY/AQX4oMLrEswmKJQQhEhXegVZPKz2YnjPohfpfyqq iXdGfQhPm096/e9mICFWsoIY/rPPLOX44Z1OimgQ= 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 5.4 107/122] ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe Date: Thu, 15 Jul 2021 20:39:14 +0200 Message-Id: <20210715182520.248548477@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182448.393443551@linuxfoundation.org> References: <20210715182448.393443551@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 @@ -596,8 +596,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: