DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] common/mlx5: fix extraction of auxiliary network device name
@ 2025-06-15  7:41 Gregory Etelson
  2025-06-26 13:14 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Gregory Etelson @ 2025-06-15  7:41 UTC (permalink / raw)
  To: dev
  Cc: getelson,  ,
	rasland, stable, Dariusz Sosnowski, Viacheslav Ovsiienko,
	Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad, Xueming Li

The PMD reads auxiliary network device name from the Linux SYSFS.

The current implementation closed directory context before it copied
a file name from that directory into internal buffer.

The patch closes SYSFS directory after file name was copied.

Fixes: 777b72a9339c ("common/mlx5: support auxiliary bus")
Cc: stable@dpdk.org

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/common/mlx5/linux/mlx5_common_auxiliary.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_auxiliary.c b/drivers/common/mlx5/linux/mlx5_common_auxiliary.c
index b4ea604820..d2a7758285 100644
--- a/drivers/common/mlx5/linux/mlx5_common_auxiliary.c
+++ b/drivers/common/mlx5/linux/mlx5_common_auxiliary.c
@@ -26,8 +26,8 @@ mlx5_auxiliary_get_child_name(const char *dev, const char *node,
 {
 	DIR *dir;
 	struct dirent *dent;
-	MKSTR(path, "%s/%s%s", AUXILIARY_SYSFS_PATH, dev, node);
 
+	MKSTR(path, "%s/%s%s", AUXILIARY_SYSFS_PATH, dev, node);
 	dir = opendir(path);
 	if (dir == NULL) {
 		rte_errno = errno;
@@ -38,14 +38,17 @@ mlx5_auxiliary_get_child_name(const char *dev, const char *node,
 		if (dent->d_name[0] != '.')
 			break;
 	}
-	closedir(dir);
 	if (dent == NULL) {
 		rte_errno = ENOENT;
-		return -rte_errno;
+		goto end;
 	}
 	if (rte_strscpy(child, dent->d_name, size) < 0)
-		return -rte_errno;
-	return 0;
+		goto end;
+	rte_errno = 0;
+
+end:
+	closedir(dir);
+	return -rte_errno;
 }
 
 static int
-- 
2.48.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] common/mlx5: fix extraction of auxiliary network device name
  2025-06-15  7:41 [PATCH] common/mlx5: fix extraction of auxiliary network device name Gregory Etelson
@ 2025-06-26 13:14 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2025-06-26 13:14 UTC (permalink / raw)
  To: Gregory Etelson
  Cc: dev, stable, mkashani, rasland, Dariusz Sosnowski,
	Viacheslav Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou,
	Matan Azrad, Xueming Li

15/06/2025 09:41, Gregory Etelson:
> The PMD reads auxiliary network device name from the Linux SYSFS.
> 
> The current implementation closed directory context before it copied
> a file name from that directory into internal buffer.
> 
> The patch closes SYSFS directory after file name was copied.
> 
> Fixes: 777b72a9339c ("common/mlx5: support auxiliary bus")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>

It was working by chance before this fix.

Applied, thanks.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-26 13:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-15  7:41 [PATCH] common/mlx5: fix extraction of auxiliary network device name Gregory Etelson
2025-06-26 13:14 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).