All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Fix issue found by coverity in drivers/cpufreq/cpufreq_stats.c
@ 2005-10-27 22:37 Jayachandran C.
  2005-10-27 23:04 ` Dave Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Jayachandran C. @ 2005-10-27 22:37 UTC (permalink / raw)
  To: cpufreq; +Cc: Andrew Morton, davej

This fixes an issue found in drivers/cpufreq/cpufreq_stats.c by Coverity. Please
review as I'm not sure if -EINVAL is the correct value to return at this point.

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>

---

 cpufreq_stats.c |    6 ++++++
 1 files changed, 6 insertions(+)

--- linux-2.6.14-rc4-git2.clean/drivers/cpufreq/cpufreq_stats.c	2005-08-28 16:41:01.000000000 -0700
+++ linux-2.6.14-rc4-git2/drivers/cpufreq/cpufreq_stats.c	2005-10-25 18:47:06.639018548 -0700
@@ -197,6 +197,11 @@
 	memset(stat, 0, sizeof (struct cpufreq_stats));
 
 	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;
 
@@ -244,6 +249,7 @@
 	return 0;
 error_out:
 	cpufreq_cpu_put(data);
+error_get_fail:
 	kfree(stat);
 	cpufreq_stats_table[cpu] = NULL;
 	return ret;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-10-27 23:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-27 22:37 [PATCH] cpufreq: Fix issue found by coverity in drivers/cpufreq/cpufreq_stats.c Jayachandran C.
2005-10-27 23:04 ` Dave Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.