Skip to contentSkip to conversation

fix cpufreq_update_policy

PATCH In review Dominik Brodowski 2 participants 4 messages Jan 28, 2004 – Jan 29, 2004 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix cpufreq_update_policy

Fix a brown paper bug in drivers/cpufreq/cpufreq.c which accessed random memory instead of the correct struct.

Please apply,

drivers/cpufreq/cpufreq.c +1 -1
diff -ruN linux-original/drivers/cpufreq/cpufreq.c linux/drivers/cpufreq/cpufreq.c
@@ -868,7 +868,7 @@
 	down(&data->lock);
 
 	memcpy(&policy, 
-	       &data, 
+	       data, 
 	       sizeof(struct cpufreq_policy));
 	policy.min = data->user_policy.min;
 	policy.max = data->user_policy.max;

_______________________________________________
Cpufreq mailing list
[email protected]
http://www.linux.org.uk/mailman/listinfo/cpufreq

#1 lore raw
Quoted 10 lines · Dominik Brodowski

Fix a brown paper bug in drivers/cpufreq/cpufreq.c which accessed random memory instead of the correct struct.

Please apply,

diff -ruN linux-original/drivers/cpufreq/cpufreq.c linux/drivers/cpufreq/cpufreq.c ---
linux-original/drivers/cpufreq/cpufreq.c 2004-01-16 20:30:59.000000000
+0100 +++ linux/drivers/cpufreq/cpufreq.c 2004-01-28 22:16:38.099398456
+0100 @@ -868,7 +868,7 @@

drivers/cpufreq/cpufreq.c line 874

Quoted 8 lines
drivers/cpufreq/cpufreq.c +1 -1
 	down(&data->lock);
 
 	memcpy(&policy,
-	       &data,
+	       data,
 	       sizeof(struct cpufreq_policy));
 	policy.min = data->user_policy.min;
 	policy.max = data->user_policy.max;

Why not change it to:

	policy = *data;

?

Signature · 1 line
Dmitry
#3 lore raw
Quoted 11 lines · Dominik Brodowski
Quoted 5 lines · Dmitry Torokhov

Why not change it to:

	policy = *data;

?

Because I doubt this works for whole structs. Or am I totally wrong (again)?

Dominik

The assignment does not work only for arrays because really arrays are constant pointers:

	char a[] == char * const a 

With structures everything is clear, size, etc. I think that K&R did not support structure assignment but I believe that it appeared at least in C89.

Signature · 1 line
Dmitry