power: fix P-state number parsing

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: de254dac60 ("power: read P-state turbo percentage from sysfs")

Signed-off-by: Markus Theil <markus.theil@secunet.com>
Reviewed-by: Reshma Pattan <reshma.pattan@intel.com>
This commit is contained in:
Markus Theil 2022-10-12 14:36:37 +02:00 committed by Thomas Monjalon
parent b127e74cce
commit e6b42038e8

View File

@ -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;