소스 검색

[CPUFREQ] Check return value of cpufreq_cpu_get in cpufreq_stats

This fixes an issue found in drivers/cpufreq/cpufreq_stats.c by Coverity.

Error reported:
CID: 2642
Checker: NULL_RETURNS (help)
File: /export2/p4-coverity/mc2/linux26/drivers/cpufreq/cpufreq_stats.c
Function: cpufreq_stats_create_table
Description: Dereferencing NULL value "data"

Patch description:
 The return of cpufreq_cpu_get can be NULL, check return code and return
 -EINVAL if it is NULL.

Signed-off-by: Jayachandran C. <c.jayachandran at gmail.com>
Signed-off-by: Dave Jones <davej@redhat.com>
Dave Jones 19 년 전
부모
커밋
bc7b26fd7c
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      drivers/cpufreq/cpufreq_stats.c

+ 5 - 0
drivers/cpufreq/cpufreq_stats.c

@@ -196,6 +196,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
 		return -ENOMEM;
 
 	data = cpufreq_cpu_get(cpu);
+	if (data == NULL) {
+		ret = -EINVAL;
+		goto error_get_fail;
+	}
+
 	if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group)))
 		goto error_out;