From: Dave Jones Date: Thu, 27 Oct 2005 23:02:06 +0000 (-0700) Subject: [CPUFREQ] Check return value of cpufreq_cpu_get in cpufreq_stats X-Git-Tag: v2.6.15-rc1~444^2~1 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc7b26fd7ca5e0c6e769d3886c022f0a98fd88ec;p=linux-2.6 [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. Signed-off-by: Dave Jones --- diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index ff16a87125..19b4c3e7c3 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/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;