[PATCH v1 2/2] examples/multi_process: fix memory leak
Wenjun Wu
wenjun1.wu at intel.com
Wed Jul 5 11:25:11 CEST 2023
The device should be detached before quit, otherwise it will
cause memory leak.
Fixes: 05f1d6842fc3 ("examples/multi_process: add hotplug sample")
Cc: stable at dpdk.org
Signed-off-by: Wenjun Wu <wenjun1.wu at intel.com>
---
examples/multi_process/hotplug_mp/commands.c | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c
index 88f44e00a0..143d57eeb6 100644
--- a/examples/multi_process/hotplug_mp/commands.c
+++ b/examples/multi_process/hotplug_mp/commands.c
@@ -52,6 +52,28 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result,
struct cmdline *cl,
__rte_unused void *data)
{
+ uint16_t port_id;
+ char dev_name[RTE_DEV_NAME_MAX_LEN];
+ struct rte_devargs da;
+
+ RTE_ETH_FOREACH_DEV(port_id) {
+ rte_eth_dev_get_name_by_port(port_id, dev_name);
+ memset(&da, 0, sizeof(da));
+
+ if (rte_devargs_parsef(&da, "%s", dev_name)) {
+ cmdline_printf(cl,
+ "cannot parse devargs for device %s\n",
+ dev_name);
+ }
+ printf("detaching before quit...\n");
+ if (!rte_eal_hotplug_remove(rte_bus_name(da.bus), da.name))
+ cmdline_printf(cl, "detached device %s\n",
+ da.name);
+ else
+ cmdline_printf(cl, "failed to detach device %s\n",
+ da.name);
+
+ }
cmdline_quit(cl);
}
--
2.34.1
More information about the stable
mailing list