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 8A8EA41C52; Thu, 9 Feb 2023 14:22:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E3D74161A; Thu, 9 Feb 2023 14:22:21 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 09AEF40EDC; Thu, 9 Feb 2023 14:22:18 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31996OlK026375; Thu, 9 Feb 2023 05:22:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Hn9+y4H5IzDZ02PRzBuB3H/kBUyYzFrUIqkR0SzuuTo=; b=ey9D90lv6wrxK+OD9i6Q2YOxgzXSfPw5EbKuzaUFtY/kA2W/uGyDOpJEqy57awPlmuLU YFsoBJxHsPQt0uBvTz7yqGVWMKZDlWPR0L3Jkyy19llNjguaFIKqw4Rk4/I8vgbspLyS jHX9v7NW1fCkN7ogJIi1jri8dkU8gQAFhaY0p9jaiQMm2iGTZZ2+6IeO8+khHQIV2PBl 9RF/cCSTf/fbBUqkytPeatMpNt6uwqTt90t9/YbeAUtIcK2RCWZA0jcwwTVaMO88uTeY uTBRzWz1xUzWUSlSnE8JrNFrS/W0qtZLOIFw3Y1kdOgIK7GpXMySY7yqCsZLz2lFfnCS gQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nm65m2ysy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Feb 2023 05:22:17 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 9 Feb 2023 05:22:15 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 9 Feb 2023 05:22:15 -0800 Received: from cavium-DT10.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 2ED5D5B692D; Thu, 9 Feb 2023 05:22:12 -0800 (PST) From: Volodymyr Fialko To: , Bruce Richardson , Kevin Laatz , =?UTF-8?q?Morten=20Br=C3=B8rup?= CC: , , Volodymyr Fialko , Subject: [PATCH v2] bus: fix leak for devices without driver Date: Thu, 9 Feb 2023 14:22:07 +0100 Message-ID: <20230209132207.1994066-1-vfialko@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230107151230.2539470-1-vfialko@marvell.com> References: <20230107151230.2539470-1-vfialko@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 9-DnhvXEPeGegJ2b0I-W6vyocziaVoL4 X-Proofpoint-ORIG-GUID: 9-DnhvXEPeGegJ2b0I-W6vyocziaVoL4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_10,2023-02-09_03,2022-06-22_01 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 the bus scan, memory for device configuration is allocated. Currently, if a driver wasn't attached to the device during initialization, memory for that device will not be released at bus cleanup. This patch address this issue and releases the memory for all allocated devices. Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown") Cc: stable@dpdk.org Signed-off-by: Volodymyr Fialko --- V2: - Updated commit message. drivers/bus/pci/pci_common.c | 3 ++- drivers/bus/vdev/vdev.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index e0e15fd624..3b4196a43b 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -450,7 +450,7 @@ pci_cleanup(void) int ret = 0; if (drv == NULL || drv->remove == NULL) - continue; + goto free; ret = drv->remove(dev); if (ret < 0) { @@ -460,6 +460,7 @@ pci_cleanup(void) dev->driver = NULL; dev->device.driver = NULL; +free: /* free interrupt handles */ rte_intr_instance_free(dev->intr_handle); dev->intr_handle = NULL; diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 41bc07dde7..7974b27295 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -578,18 +578,19 @@ vdev_cleanup(void) int ret = 0; if (dev->device.driver == NULL) - continue; + goto free; drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver); if (drv->remove == NULL) - continue; + goto free; ret = drv->remove(dev); if (ret < 0) error = -1; dev->device.driver = NULL; +free: free(dev); } -- 2.34.1