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

Alex Hung alex.hung at canonical.com
Wed Sep 9 03:21:01 UTC 2015


On 09/08/2015 03:00 PM, 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: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list