X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_power%2Fpower_acpi_cpufreq.c;h=7c386f891ebdaf2a6054c927469652abaecd6357;hb=cddd879540daf1f1f34f6ade34ebd3cbf069ff96;hp=cd5978d5b312c831ec55a4bb2a5efc337e9e12ef;hpb=185109906b809007a15db1d018100dc74ec37447;p=dpdk.git diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index cd5978d5b3..7c386f891e 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -12,8 +12,10 @@ #include #include -#include #include +#include +#include +#include #include "power_acpi_cpufreq.h" #include "power_common.h" @@ -147,6 +149,8 @@ power_set_governor_userspace(struct rte_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is userspace */ if (strncmp(buf, POWER_GOVERNOR_USERSPACE, @@ -157,7 +161,7 @@ power_set_governor_userspace(struct rte_power_info *pi) goto out; } /* Save the original governor */ - snprintf(pi->governor_ori, sizeof(pi->governor_ori), "%s", buf); + strlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori)); /* Write 'userspace' to the governor */ val = fseek(f, 0, SEEK_SET); @@ -166,6 +170,10 @@ power_set_governor_userspace(struct rte_power_info *pi) val = fputs(POWER_GOVERNOR_USERSPACE, f); FOPS_OR_ERR_GOTO(val, out); + /* We need to flush to see if the fputs succeeds */ + val = fflush(f); + FOPS_OR_ERR_GOTO(val, out); + ret = 0; RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been " "set to user space successfully\n", pi->lcore_id); @@ -436,8 +444,13 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) { struct rte_power_info *pi; - if (lcore_id >= RTE_MAX_LCORE || !freqs) { - RTE_LOG(ERR, POWER, "Invalid input parameter\n"); + if (lcore_id >= RTE_MAX_LCORE) { + RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + return 0; + } + + if (freqs == NULL) { + RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); return 0; }