patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: getelson@nvidia.com,   <mkashani@nvidia.com>,
	rasland@nvidia.com, stable@dpdk.org,
	"Dariusz Sosnowski" <dsosnowski@nvidia.com>,
	"Viacheslav Ovsiienko" <viacheslavo@nvidia.com>,
	"Bing Zhao" <bingz@nvidia.com>, "Ori Kam" <orika@nvidia.com>,
	"Suanming Mou" <suanmingm@nvidia.com>,
	"Matan Azrad" <matan@nvidia.com>,
	"Xueming Li" <xuemingl@nvidia.com>
Subject: [PATCH] common/mlx5: fix extraction of auxiliary network device name
Date: Sun, 15 Jun 2025 10:41:29 +0300	[thread overview]
Message-ID: <20250615074129.52396-1-getelson@nvidia.com> (raw)

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


                 reply	other threads:[~2025-06-15  7:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250615074129.52396-1-getelson@nvidia.com \
    --to=getelson@nvidia.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=mkashani@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    --cc=xuemingl@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).