lib/power: fix return code to unsigned value

Message ID 20190107144023.7041-1-david.hunt@intel.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • lib/power: fix return code to unsigned value
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

David Hunt Jan. 7, 2019, 2:40 p.m.
The power_pstate_cpufreq_freqs() function was returning -1 in an
unsigned int, causing buffer over-runs when the results were being
processed. This function should be returning zero for all error
conditions, similar to it's acpi relation, power_acpi_cpufreq_freqs().

Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility")

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 lib/librte_power/power_pstate_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Monjalon Jan. 14, 2019, 10:55 p.m. | #1
07/01/2019 15:40, David Hunt:
> The power_pstate_cpufreq_freqs() function was returning -1 in an
> unsigned int, causing buffer over-runs when the results were being
> processed. This function should be returning zero for all error
> conditions, similar to it's acpi relation, power_acpi_cpufreq_freqs().
> 
> Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility")
> 
> Signed-off-by: David Hunt <david.hunt@intel.com>

Applied, thanks

Patch

diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index 0a566eb07..9ec5da511 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -577,7 +577,7 @@  power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 
 	if (lcore_id >= RTE_MAX_LCORE) {
 		RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
-		return -1;
+		return 0;
 	}
 
 	if (freqs == NULL) {