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 40F694221D for ; Fri, 1 Sep 2023 09:35:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D323402A2; Fri, 1 Sep 2023 09:35:17 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id C39734014F; Fri, 1 Sep 2023 09:35:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693553714; x=1725089714; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=TWmEkPseNI407vCJR7cRjO+zt5iKzFj7chl8pzeEAQ8=; b=jHIFoFfPuRRjCCD+/Ri23b36EBtLJGWdifv8mjn3THGyE1pqrlVb3tSb OPIrZ9bBgBH3ZyceXhGvDfDTJsbB2FSiXvz5N3stVMjI9avA7xKjsr2ep yJkdKbP5tsNlmeAebIqUHnYJKK+G/1a/y5fUwttguKFrlp7bx6QPMNFiv Q2BVoHCYfVaCDhPrATyFm3vpFKDS1F20xI0en8y72DVlFpdhRvNciWXox Uzjhr5wAyuSkmBPlI1sI1rfkZIoF72V8yD3yvP9GPIzsBYqz8Z6Bkn3to RNbtn66hZTOQWwoDath+PDva1A2OzV022elUwYHvvzbr2KvxEWJACcdBj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10819"; a="442551996" X-IronPort-AV: E=Sophos;i="6.02,219,1688454000"; d="scan'208";a="442551996" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2023 00:35:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10819"; a="1070639878" X-IronPort-AV: E=Sophos;i="6.02,219,1688454000"; d="scan'208";a="1070639878" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2023 00:35:11 -0700 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, yidingx.zhou@intel.com, Mingjin Ye , stable@dpdk.org, Anatoly Burakov Subject: [PATCH] bus/vdev: fix devargs memory leak Date: Fri, 1 Sep 2023 07:24:09 +0000 Message-Id: <20230901072409.741847-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 When a device is created by a secondary process, an empty devargs is temporarily generated and bound to it. This causes the device to not be associated with the correct devargs, and the empty devargs are not released when the resource is freed. This patch fixes the issue by matching the devargs when inserting a device in secondary process. Fixes: dda987315ca2 ("vdev: make virtual bus use its device struct") Fixes: a16040453968 ("eal: extract vdev infra") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye --- drivers/bus/vdev/vdev.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 7974b27295..fe39a98a9c 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -259,6 +259,22 @@ alloc_devargs(const char *name, const char *args) return devargs; } +static struct rte_devargs * +vdev_devargs_lookup(const char *name) +{ + struct rte_devargs *devargs; + char dev_name[32]; + + RTE_EAL_DEVARGS_FOREACH("vdev", devargs) { + devargs->bus->parse(devargs->name, &dev_name); + if (strcmp(dev_name, name) == 0) { + VDEV_LOG(INFO, "**Devargs matched %s", dev_name); + return devargs; + } + } + return NULL; +} + static int insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev, @@ -271,7 +287,11 @@ insert_vdev(const char *name, const char *args, if (name == NULL) return -EINVAL; - devargs = alloc_devargs(name, args); + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + devargs = alloc_devargs(name, args); + else + devargs = vdev_devargs_lookup(name); + if (!devargs) return -ENOMEM; -- 2.25.1