fix incorrect initialization code for trans_stat of devfreq
PATCH 1/1 fix incorrect initialization code for trans_stat of devfreq
Hi,
I met trans_stat abnormal issue while debugging devfreq feature for ddr in arm64 system, cat trans_stat would get extremely large time value which is unreasonable, I checked the code and found it was caused by incorrect initialization code, time_in_state is initialized by devm_kzalloc and wrongly use sizeof(unsigned int) as argument, but time_in_state which is defined in struct devfreq actually is defined as unsigned long, so it is ok for 32 bit system, but will cause unexpected result in 64 bit system.
Xiaolong Ye (1):
PM / devfreq: Fix incorrect type issue.
drivers/devfreq/devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
1.7.9.5
PATCH 1/1 PM / devfreq: Fix incorrect type issue.
time_in_state in struct devfreq is defined as unsigned long, so devm_kzalloc should use sizeof(unsigned long) as argument instead of sizeof(unsigned int), otherwise it will cause unexpected result in 64bit system.
--- drivers/devfreq/devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/devfreq/devfreq.c +1 -1
@@ -482,7 +482,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->profile->max_state * devfreq->profile->max_state, GFP_KERNEL); - devfreq->time_in_state =devm_kzalloc (dev,sizeof (unsigned int ) * + devfreq->time_in_state =devm_kzalloc (dev,sizeof (unsigned long ) * devfreq->profile->max_state,GFP_KERNEL ); devfreq->last_stat_updated = jiffies;
Signature · 1 line
1.7.9.5