DPDK patches and discussions
 help / color / mirror / Atom feed
From: Markus Theil <markus.theil@tu-ilmenau.de>
To: David Hunt <david.hunt@intel.com>
Cc: dev@dpdk.org, Markus Theil <markus.theil@secunet.com>,
	Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH v2] power: fix pstate number parsing
Date: Wed, 12 Oct 2022 14:36:37 +0200	[thread overview]
Message-ID: <20221012123637.51640-1-markus.theil@tu-ilmenau.de> (raw)
In-Reply-To: <20221012113342.7931-1-markus.theil@tu-ilmenau.de>

From: Markus Theil <markus.theil@secunet.com>

When converting atoi to strtol in a revision
of introducing sysfs support for turbo percentage,
a necessary check against '\n' returned by sysfs
was not introduced.

Fixes: de254dac608e ("power: read P-state turbo percentage from sysfs")
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
Acked-by: Reshma Pattan <reshma.pattan@intel.com>
Signed-off-by: Markus Theil <markus.theil@secunet.com>
---
 lib/power/power_pstate_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c
index 49ddb2eefd..52aa64510e 100644
--- a/lib/power/power_pstate_cpufreq.c
+++ b/lib/power/power_pstate_cpufreq.c
@@ -96,7 +96,7 @@ power_read_turbo_pct(uint64_t *outVal)

 	errno = 0;
 	*outVal = (uint64_t) strtol(val, &endptr, 10);
-	if (*endptr != 0 || errno != 0) {
+	if (errno != 0 || (*endptr != 0 && *endptr != '\n')) {
 		RTE_LOG(ERR, POWER, "Error converting str to digits, read from %s: %s\n",
 				 POWER_SYSFILE_TURBO_PCT, strerror(errno));
 		ret = -1;
--
2.38.0


  parent reply	other threads:[~2022-10-12 12:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12 11:33 [PATCH] " Markus Theil
2022-10-12 12:25 ` Pattan, Reshma
2022-10-26 21:33   ` Thomas Monjalon
2022-10-12 12:36 ` Markus Theil [this message]
2022-10-26 21:35   ` [PATCH v2] " 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=20221012123637.51640-1-markus.theil@tu-ilmenau.de \
    --to=markus.theil@tu-ilmenau.de \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=markus.theil@secunet.com \
    --cc=reshma.pattan@intel.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).