Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp660170pxv; Thu, 15 Jul 2021 12:45:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMVQDFUYGlXu0cSZVyR02taN4mIuj/olX8HFCRktHh/GCsvR4Km+ZTkUXzMjHeBOTQCe39 X-Received: by 2002:a17:907:1b29:: with SMTP id mp41mr7074254ejc.459.1626378343373; Thu, 15 Jul 2021 12:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378343; cv=none; d=google.com; s=arc-20160816; b=TBrDoQnFrFCgpnOGREHtgEF6kLYVhhG5JQbcP6kqH349Ur/6/Cm21U+hY3yVubqmVL KnNoapa+yCc4AOJ4sKblN8OjAzFkWNXLixEgF6YYqJJuJsq1RDL3cRNNeQuYQT3XuRxk HbYohbbSPO4nQLNzv4K787kJp2mnEQvHWN8VwzG1M5njuxoJB4+rORb7e9EL/T/yay+y 6njbQ9erDwUeoOqm9iXc+hyPgzLQa+Ntvd+jNlO+SWQbpwKzXn5kq104qsLE4hbaHn62 ZMr27aVHn1JM5HDlsqiXBIAhaXYePVTzuaSVr5ntDs2Bzz1Jsyd24wirWM03frBVHMmP l6Wg== 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=b57myBqG+eH1xd0ndzbEVQfG8x7AxzSCuOj4CcRqNBRVgDUq7aPY3aXqNHrmrvL3D9 s5YnvNPDncEN97SAbktVPmcoj6LuVMvK2O2C0+OyYrNqq+r5YwxCo1JUCLDuEfjjgEqX XbTA/FBX8TzAcEOexJWPC8JA6oNnZbzxBwPKYw5sNuexneeaUUpW7fpIJn0WXGufsNKy uGDL2jNhg9QrAHBa87y+EcZACfTjFgPTxfJws6ezWYGGeVZufkqra1yFaovKe+YsTfri m4yO+KznQ5laZBR1I7aSUKDm1RmDgFpe7GOg9IIVN9qsrxcGaAprw3CH4uZlRM5FUwZo 9Q4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B0foQxbE; 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 y17si8404935edv.241.2021.07.15.12.45.20; Thu, 15 Jul 2021 12:45:43 -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=B0foQxbE; 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 S1343660AbhGOTrT (ORCPT + 99 others); Thu, 15 Jul 2021 15:47:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:57714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244584AbhGOTQe (ORCPT ); Thu, 15 Jul 2021 15:16:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B3E97613D4; Thu, 15 Jul 2021 19:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376358; bh=oDj4QzskaiCbEtmnzszlg04IE4Xh1gAq207OnqONIEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B0foQxbEdEVlMZBGZoubz1yoVCSF7H6Ltr1EwJNDs+VgYO8qj6v1YIC+Y1pc7F6aK BmG8qZ4vryZd56vP5zUf1KzojnbzfDJnhJVHTmEGssOPkgAWI68+iUQ/tkxkdZdxW7 xe2Fee/ODKpyoTKe7QX3zn4zMILKSL51PZfxXI2U= 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.13 236/266] ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe Date: Thu, 15 Jul 2021 20:39:51 +0200 Message-Id: <20210715182650.604229079@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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: