ACK: [PATCH 1/4] cpu: maxfreq: check for unlikely event that no CPUs in cpu list

ivanhu ivan.hu at canonical.com
Tue Sep 8 09:31:35 UTC 2015



On 2015年09月08日 15:00, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> there is a very unlikely possibility that the cpu list contains
> no CPU information, so add a check for this corner case.
>
> Found using clang's static analyzer
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/cpu/maxfreq/maxfreq.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
> index 031b13c..b424b17 100644
> --- a/src/cpu/maxfreq/maxfreq.c
> +++ b/src/cpu/maxfreq/maxfreq.c
> @@ -78,6 +78,11 @@ static int maxfreq_test1(fwts_framework *fw)
>   		if (strstr(fwts_text_list_text(item), "model name"))
>   			cpus++;
>   	}
> +	if (!cpus) {
> +		fwts_log_error(fw, "Cannot find any CPUs.");
> +		fwts_list_free(cpuinfo, free);
> +		return FWTS_ERROR;
> +	}
>
>   	if ((cpufreq = calloc(cpus, sizeof(double))) == NULL) {
>   		fwts_log_error(fw, "Cannot create cpu frequency array.");
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list