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 75B7EA00C2; Sat, 7 Jan 2023 16:12:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5ED094021D; Sat, 7 Jan 2023 16:12:41 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 1590140141 for ; Sat, 7 Jan 2023 16:12:38 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 307EWF7x014495; Sat, 7 Jan 2023 07:12:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=ESZEdtHEe1FZ9EkR7hy7Tjy1vO6/qowL4C86DiIHbJk=; b=Os8P2hRRGJQn+q8mBvqS3f9jnxKD1c226tQJGSTWYwBv40Q4pSg7MBui8GrK++2ot9pi PDdjaG9hYQGvtlPGVumMgLmINRwSyRCSyBye+j4D4OiX6wxHo7GTgy7KWrauLqzxwjnK 3wedX81WY4I6F/hBuQW4mhGPie7YmE677XiG03OW/njyKYLlMbGSF/b9MI1jBeesm/lk dPC9WjMlh1fYJEqaoKWHoCIomBo65fSUyhPvnLw7IcPJQfzaiRBz0zr3DQ9FqUFEwn9x zt5di/sO4QS3UZ/aRdHRpS42xjNRAl0RSWD7FqDtHkHLDBO9Ml000IOV40WfrcrHySPa Bg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3my6yw0a0p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 07 Jan 2023 07:12:37 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 7 Jan 2023 07:12:36 -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; Sat, 7 Jan 2023 07:12:36 -0800 Received: from cavium-DT10.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 1DF5A5B692A; Sat, 7 Jan 2023 07:12:33 -0800 (PST) From: Volodymyr Fialko To: , Bruce Richardson , Kevin Laatz , =?UTF-8?q?Morten=20Br=C3=B8rup?= CC: , Volodymyr Fialko Subject: [PATCH] bus: fix leak for devices without driver Date: Sat, 7 Jan 2023 16:12:30 +0100 Message-ID: <20230107151230.2539470-1-vfialko@marvell.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: IBoziJnp1vH1XYicilfCzzWZrVnFf8hC X-Proofpoint-ORIG-GUID: IBoziJnp1vH1XYicilfCzzWZrVnFf8hC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-07_06,2023-01-06_01,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 For devices not assigned to any driver, we leak a pci device object since it is never freed from the PCI bus device list, reported by ASAN. Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown") Signed-off-by: Volodymyr Fialko --- 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 bc3a7f39fe..e32a9d517a 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -448,7 +448,7 @@ pci_cleanup(void) int ret = 0; if (drv == NULL || drv->remove == NULL) - continue; + goto free; ret = drv->remove(dev); if (ret < 0) { @@ -458,6 +458,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