common/mlx5: fix extraction of auxiliary network device name
PATCH 1/1 common/mlx5: fix extraction of auxiliary network device name
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")
Signed-off-by Gregory Etelson <[email protected]>
--- drivers/common/mlx5/linux/mlx5_common_auxiliary.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/common/mlx5/linux/mlx5_common_auxiliary.c +8 -5
@@ -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
Signature · 1 line
2.48.1
Thomas Monjalon
Applied15/06/2025 09:41, Gregory Etelson:
Quoted 5 lines
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.
Quoted 7 lines
The patch closes SYSFS directory after file name was copied.
Fixes 777b72a9339c ("common/mlx5: support auxiliary bus")Signed-off-by Gregory Etelson <[email protected]>
It was working by chance before this fix.
Applied, thanks.