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 5C6AFA0584; Wed, 19 Oct 2022 12:46:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 23014410D1; Wed, 19 Oct 2022 12:46:31 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 17C7840E03 for ; Wed, 19 Oct 2022 12:46:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666176389; x=1697712389; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=EZP/L+ThsmyenDV+qwTqpgHBsdUL3qCXc/RQ1DQ7s0Q=; b=i6o6yYfzOaIjhfT3MtKVTsIb9W1263yOWSmheoNjdaZVNNbs49fQu8eN SWhL4f8sgO8bxnDAY/5OdwXuc17vCYuSFTqSfuykKkw8feb/RGBGVO9Mu ZjSjd9Y1N/QkNnFeLsiPmpRXrDuxG9tjOWBjVxW3Qm9Y6OVDGqTl6wM/9 ANEYVCNNAV0Q5HHw8AszRWMuRT/63ohhUAqoEBb6fAmso/c+LycONjglf i7O3sfeBIxQKtzVhFkLToiHUYBKFsXEjJ5rg0bAOvWFPdEaXPpf3eHti8 FM0uL2P8eFrFfRm8AZ3kjxR2+LYJIfcF7MjslqmBBr/mguPeqzliOJs6z g==; X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="286765152" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="286765152" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2022 03:46:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10504"; a="629198338" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="629198338" Received: from silpixa00401122.ir.intel.com ([10.243.22.75]) by orsmga002.jf.intel.com with ESMTP; 19 Oct 2022 03:46:26 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz , Bruce Richardson , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH] bus: fix memleak during pci device cleanup Date: Wed, 19 Oct 2022 11:49:23 +0100 Message-Id: <20221019104923.1240394-1-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org During PCI bus device cleanup some interrupt handle pointers and the bus_info pointer are not being free'd, leading to memory leaks. This patch fixes the memory leaks by ensuring they are free'd during device cleanup on exit. Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown") Signed-off-by: Kevin Laatz --- drivers/bus/pci/pci_common.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 7f598667fe..330a41ed12 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -456,6 +456,20 @@ pci_cleanup(void) } dev->driver = NULL; dev->device.driver = NULL; + + /* free interrupt handles */ + if (dev->intr_handle != NULL) { + rte_intr_instance_free(dev->intr_handle); + dev->intr_handle = NULL; + rte_intr_instance_free(dev->vfio_req_intr_handle); + dev->vfio_req_intr_handle = NULL; + } + + if (dev->bus_info != NULL) { + free(dev->bus_info); + dev->bus_info = NULL; + } + free(dev); } -- 2.31.1