From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D7E85A0540 for ; Mon, 4 Jul 2022 15:23:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B06D540E09; Mon, 4 Jul 2022 15:23:45 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id CD2F040E09; Mon, 4 Jul 2022 15:23:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656941024; x=1688477024; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=gGJ0RjqXegAyrGSVwyM2MtMXYJMwu9+67xGC3eDctO0=; b=BXy78UeoJcIkbZd+tiZPWVioJZ9htwRBXGZHJ8h0YCc2VwG9z3898PvG b31MmTqJlGP+/xsNhrMVkIVY4aRNkJ6Rl33bolP/UfwAXS+0Il3tKHd36 6LJwHo0ai1S4OUKGrPwFBjppN0F/mzRmMYun140Flost3owOcZBYeMW4L f++FCg9DmEkZPdKeaAPA+/ffbxsKW0tRqHJOSFnmht3IE/K9YfAKMPUs3 T6ahO9I3QIQbG5p5Sj5EJ0KO3tWCjUDAaS66x9bwCO3EwvjSVhIpRG9Px VnwrbRgbvm9bOsYp/VOWtHpLmymMvB84UYq721CPWeDdxqLEkrjJbctX/ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10397"; a="263552449" X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="263552449" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 06:23:42 -0700 X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="619292084" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.1.180]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 04 Jul 2022 06:23:41 -0700 Date: Mon, 4 Jul 2022 14:23:38 +0100 From: Bruce Richardson To: Kevin Laatz Cc: dev@dpdk.org, stable@dpdk.org Subject: Re: [PATCH v2 2/3] dma/idxd: fix memory leak due to free on incorrect pointer Message-ID: References: <20220408141504.1319913-1-kevin.laatz@intel.com> <20220703122243.929642-1-kevin.laatz@intel.com> <20220703122243.929642-3-kevin.laatz@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220703122243.929642-3-kevin.laatz@intel.com> X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Sun, Jul 03, 2022 at 01:22:42PM +0100, Kevin Laatz wrote: > During PCI device close, any allocated memory needs to be free'd. > Currently, one of the free's is being called on an incorrect idxd_dmadev > struct member, namely 'batch_idx_ring', causing a memleak from the > pointer that should have been free'd. I think you need to explain that the two rings are beside each other in memory and we need to free using the pointer to the start of the block, rather than the pointer to the middle of it. > This patch fixes this memleak by calling free on the correct pointer. > > Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe") > Cc: stable@dpdk.org > Cc: bruce.richardson@intel.com > > Signed-off-by: Kevin Laatz With more explanation in the commit log Signed-off-by: Bruce Richardson > --- > drivers/dma/idxd/idxd_pci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c > index 918981f2ea..9349c56b3f 100644 > --- a/drivers/dma/idxd/idxd_pci.c > +++ b/drivers/dma/idxd/idxd_pci.c > @@ -130,7 +130,7 @@ idxd_pci_dev_close(struct rte_dma_dev *dev) > > /* free device memory */ > IDXD_PMD_DEBUG("Freeing device driver memory"); > - rte_free(idxd->batch_idx_ring); > + rte_free(idxd->batch_comp_ring); > rte_free(idxd->desc_ring); > > /* if this is the last WQ on the device, disable the device and free > -- > 2.31.1 >