From: David Hunt Date: Mon, 7 Jan 2019 14:39:34 +0000 (+0000) Subject: power: fix frequency list to handle null buffer X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2e6ccdb4e0887e881de97fe51a038cacca1aedad;p=dpdk.git power: fix frequency list to handle null buffer This patch fixes a segfault in the case where a null buffer is passed to the following functions: power_acpi_cpufreq_freqs() power_pstate_cpufreq_freqs() Fixes: 445c6528b55f ("power: common interface for guest and host") Signed-off-by: David Hunt --- diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index f50897b4dd..45412f0b99 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -445,6 +445,11 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) return 0; } + if (freqs == NULL) { + RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + return 0; + } + pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { RTE_LOG(ERR, POWER, "Buffer size is not enough\n"); diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 0f8e8f9706..9111e6a577 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -584,6 +584,11 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) return -1; } + if (freqs == NULL) { + RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + return 0; + } + pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { RTE_LOG(ERR, POWER, "Buffer size is not enough\n");