Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp349722pxj; Thu, 20 May 2021 10:43:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf5A1UVhGRbTndPohlmgEH/ihk01ZIzziEpTKBUT7qqMh8ITJHKEG63UWNm06ciOG9JEnP X-Received: by 2002:a02:b78c:: with SMTP id f12mr7769558jam.7.1621532585324; Thu, 20 May 2021 10:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532585; cv=none; d=google.com; s=arc-20160816; b=gYRCBOzo2yfBPAITE5YYiw9EFa2dVNbCYnNdFUUoA/M0iNO0awNlJS3rsCD7tYe0hr AQvC3rS60b6/acndWcBj6T8p3Unqu08T0+YgrVQnsyLY3GoWPMsF70YOIAbb8R2J2OdE NLaIrci50KvNvTYs2jGrXNJbg1Smbyl/epEImJUOO2yO5Pup9T96aXJBVyDCB7tnvDw0 awNnVUqDaL3rVoxijXe3QqNQB5FMcnSweGEEnKbzudXrk9VeqGnz93v2BQO6s/MwO3yr tuI1KNNR37ZOi/0fDa8fdGuVnU8Pozwtp66k/2x1Xow2+aJx65e9gHLeUsjPcbcceLP+ HGxw== 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=Q4MTibc2YriD8ByPUTC3voJlh9yPgvCP033VtftaiGA=; b=GGIbXeyzUs56tUDAvKSV1ahQfhr2XtXwS+vGOUnGoo1SGzeMBHW9NVmXG5tU1EDx+5 qKwZAzzrd5nJiCmpxnFkTuAvSK7yR56aGP3SL183b6xCXRcafMKoBX78FBGvQHEDpzGK a4vaNbKSAiUWednyhnEFd8bGdEXwOhZEx4xcRCkNGRgijx0JPzg4ZTe6y8dDAf8KIHXQ H7Z5NdvILQf7FA7lO0xqWq+/1xaLRVTYftFPvpwoir/Di48ATFuglDvZ44RmulD2FuIK rBnj60CW5ML1ZYo5CqzKj4dhj/rzOn4AZlOGtEl52MQfS+Sqj2ev2izQaPdVEQGnfxmx Jqxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cVb9+J0B; 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 b26si2851914ios.29.2021.05.20.10.42.51; Thu, 20 May 2021 10:43:05 -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=cVb9+J0B; 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 S235554AbhETKLa (ORCPT + 99 others); Thu, 20 May 2021 06:11:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235217AbhETKDX (ORCPT ); Thu, 20 May 2021 06:03:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F43061423; Thu, 20 May 2021 09:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503606; bh=D513QAe6+ds8yHQQ538gonVJ6YmkA0l+bGeNrXMecJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cVb9+J0B+F7pmlJWAYy+zW1p/v4ThdL+xLn67EKWudc55Zw6sj16tuSxlrKPiMCuG +ftLFsolOCtWiPVAayNh1LlCPULL31GJJny8jfXInC38O1gZVdCsHkG5bBDV/zu4Ev I2f7R6OuHjlGrV0nCjDj4QhsfUeOZ2vVeKxo92Og= 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 4.19 290/425] RDMA/bnxt_re: Fix a double free in bnxt_qplib_alloc_res Date: Thu, 20 May 2021 11:20:59 +0200 Message-Id: <20210520092140.982238864@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 539a5d44e6db..655952a6c0e6 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c @@ -725,6 +725,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