Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4631524pxj; Wed, 12 May 2021 09:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlkPT2Y9Ph0kuyCfKbn3X5DQxxmUFxi7VuohGHaK9V5u4yeQ59IujrXrSaUtFSQ22VsQxz X-Received: by 2002:a2e:2f14:: with SMTP id v20mr20822887ljv.363.1620837496307; Wed, 12 May 2021 09:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837496; cv=none; d=google.com; s=arc-20160816; b=DzCXf0ErqiSHoKWyYCIbheueC6MmmBAStsZNo9RY0RRU7koHofLkm0FBs8RhK2/hMQ ZhptKdvqhHafP0RnWgU7UFXeVjIMrpETPvjQMwHZwjtjdni34e3HPGFVWzBglWZVfYlL 4WQy1JdJVjE96il/QS2TmZlDXAm6UU4u/2rWfi8N3YKF//cem9mAWRQvV/dowtlLoYOr +YibFoI/FSgXwMcihhXQHbxjfBYwBoN6ZXQAjCYOif9Zl/EM4MZjYBQGsN+vTOLNC9g0 GjIMAmffihzEYzRIjm6PfDYuWlvyBTXOPWQT12kFu9pGTWqWG7DGNiq6cq/HR3FipT8k 5VYA== 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=lMN9wmPFWUalDT72wxqHsYmgbkGDhrYiLCuabfrDJ6k=; b=cOnLlXEEOcs+yX8FNNyQIiXLodAMxsFo7MutGOAVV9vT4/WnpAPuSvWzgeIfTZgvva DG82KQXy53DSK0MEfpEhuag0BMiYM8ILXVyywTdsljwwgUTgQhltl8hUZz8uS15gCivb JFlEJYWCeSgDyK/lUzVlOttXCqtAw75Ja7hON64nPNABCfPwX21V3gAKDLi9W0TqJoZb ZNn480MiFslBZfdeioJ54OsmU+NohRjg6aiRpnr8yogae6cCsajj+Ktfb0PSGVNYknSG 066x8kY8hgx4pd4Yf+CcMyae87fPDL2mAsAWYn1tebSfcY0+W5ZBBTbln88dRSBbMpk8 ACCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V3E77AaD; 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 a26si287160ljq.131.2021.05.12.09.37.43; Wed, 12 May 2021 09:38:16 -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=V3E77AaD; 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 S234479AbhELQhP (ORCPT + 99 others); Wed, 12 May 2021 12:37:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:43610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236665AbhELPpk (ORCPT ); Wed, 12 May 2021 11:45:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0F34619A7; Wed, 12 May 2021 15:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833004; bh=Wz1vQYGjMtqr2LWXbeUWRRYsqD4GG77I2JGVxe91OnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V3E77AaDPhaAxQhhtNg8bFUoUq6ApTzh2BUmSGGYRcDh9mkV7g1mfHPvNIAwuzTyE RwXpA5YsZXekhZ21PYx4E3To191ZJW3Rj93mJKEVwsHwSCGBWnaQ2GPJos9sJOwEjg LFGDUDw5j31vHvn/zaNTDQ6tHpIBmhnQmE14U3gA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , Leon Romanovsky , Devesh Sharma , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 509/530] RDMA/bnxt_re: Fix a double free in bnxt_qplib_alloc_res Date: Wed, 12 May 2021 16:50:19 +0200 Message-Id: <20210512144836.490247199@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 [ Upstream commit 34b39efa5ae82fc0ad0acc27653c12a56328dbbe ] In bnxt_qplib_alloc_res, it calls bnxt_qplib_alloc_dpi_tbl(). Inside bnxt_qplib_alloc_dpi_tbl, dpit->dbr_bar_reg_iomem is freed via pci_iounmap() in unmap_io error branch. After the callee returns err code, bnxt_qplib_alloc_res calls bnxt_qplib_free_res()->bnxt_qplib_free_dpi_tbl() in the fail branch. Then dpit->dbr_bar_reg_iomem is freed in the second time by pci_iounmap(). My patch set dpit->dbr_bar_reg_iomem to NULL after it is freed by pci_iounmap() in the first time, to avoid the double free. Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver") Link: https://lore.kernel.org/r/20210426140614.6722-1-lyl2019@mail.ustc.edu.cn Signed-off-by: Lv Yunlong Reviewed-by: Leon Romanovsky Acked-by: Devesh Sharma Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c index fa7878336100..3ca47004b752 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c @@ -854,6 +854,7 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res, unmap_io: pci_iounmap(res->pdev, dpit->dbr_bar_reg_iomem); + dpit->dbr_bar_reg_iomem = NULL; return -ENOMEM; } -- 2.30.2