DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tduszynski@marvell.com>
To: <dev@dpdk.org>, Tomasz Duszynski <tduszynski@marvell.com>
Subject: [PATCH 1/2] bus/platform: fix resource names iteration
Date: Thu, 16 Mar 2023 10:41:32 +0100	[thread overview]
Message-ID: <20230316094133.237641-1-tduszynski@marvell.com> (raw)

Fix stop condition and make sure we have some
sentinel at the end of buffer to make sure
loop can properly terminate.

Coverity issue: 383661
Fixes: 17c839f74da3 ("bus: add platform bus")

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
---
 drivers/bus/platform/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c
index 536d9524c6..a2faacdf18 100644
--- a/drivers/bus/platform/platform.c
+++ b/drivers/bus/platform/platform.c
@@ -249,11 +249,11 @@ of_resource_name(const char *dev_name, int index)
 	char *name;
 
 	snprintf(path, sizeof(path), PLATFORM_BUS_DEVICES_PATH "/%s/of_node/reg-names", dev_name);
-	ret = read_sysfs_string(path, buf, sizeof(buf));
+	ret = read_sysfs_string(path, buf, sizeof(buf) - 1);
 	if (ret)
 		return NULL;
 
-	for (name = buf; name; name += strlen(name) + 1) {
+	for (name = buf; *name != 0; name += strlen(name) + 1) {
 		if (num++ != index)
 			continue;
 		return strdup(name);
-- 
2.34.1


             reply	other threads:[~2023-03-16  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16  9:41 Tomasz Duszynski [this message]
2023-03-16  9:41 ` [PATCH 2/2] bus/platform: do not allow adding existing device Tomasz Duszynski
2023-03-16 16:52   ` Thomas Monjalon

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=20230316094133.237641-1-tduszynski@marvell.com \
    --to=tduszynski@marvell.com \
    --cc=dev@dpdk.org \
    /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).