From patchwork Wed Oct 12 11:33:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 118050 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D1270A0093; Wed, 12 Oct 2022 13:33:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C143E42EF7; Wed, 12 Oct 2022 13:33:45 +0200 (CEST) Received: from smail.rz.tu-ilmenau.de (smail.rz.tu-ilmenau.de [141.24.186.67]) by mails.dpdk.org (Postfix) with ESMTP id 3352842D6E for ; Wed, 12 Oct 2022 13:33:45 +0200 (CEST) Received: from localhost.localdomain (dialin-ip-23-165.ilmenau.net [80.88.23.165]) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPA id BB310580083; Wed, 12 Oct 2022 13:33:44 +0200 (CEST) From: Markus Theil To: David Hunt Cc: dev@dpdk.org, Markus Theil Subject: [PATCH] power: fix pstate number parsing Date: Wed, 12 Oct 2022 13:33:42 +0200 Message-Id: <20221012113342.7931-1-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Markus Theil 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") Signed-off-by: Markus Theil Reviewed-by: Reshma Pattan Acked-by: Reshma Pattan --- lib/power/power_pstate_cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 49ddb2eefd..7e660618db 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -2,6 +2,7 @@ * Copyright(c) 2018 Intel Corporation */ +#include #include #include #include @@ -96,7 +97,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;