Skip to contentSkip to conversation

PM / devfreq: Allocate memory using the right data type

PATCH In review Saravana Kannan 3 participants 3 messages Jul 16, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM / devfreq: Allocate memory using the right data type

From: Suman Tatiraju <[email protected]>

Long and int have different sizes on a 64-bit machine. Allocate memory for the time_in_state table using the right data type.

Change-Id I335277674018c0ea759aa0996309d52578ea1fd5
---
 drivers/devfreq/devfreq.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/devfreq/devfreq.c +4 -3
index 65eed38..349e28ea 100644
@@ -483,9 +483,10 @@ 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->profile->max_state,
-						GFP_KERNEL);
+	devfreq->time_in_state = devm_kzalloc(dev,
+					sizeof(*(devfreq->time_in_state)) *
+					devfreq->profile->max_state,
+					GFP_KERNEL);
 	devfreq->last_stat_updated = jiffies;
 
 	dev_set_name(&devfreq->dev, "%s", dev_name(dev));
Signature · 4 lines
1.8.2.1

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw
Quoted 6 lines · Saravana Kannan

From: Suman Tatiraju <[email protected]>

Long and int have different sizes on a 64-bit machine. Allocate memory for the time_in_state table using the right data type.

Change-Id: I335277674018c0ea759aa0996309d52578ea1fd5

Please don't put this crud in patches you submit upstream. It means nothing to us.

Quoted 6 lines
---
 drivers/devfreq/devfreq.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>

#2 lore raw
In reply to Saravana Kannan
Quoted 5 lines · Saravana Kannan
drivers/devfreq/devfreq.c +0 -0
index 65eed38..349e28ea 100644

drivers/devfreq/devfreq.c struct devfreq *devfreq_add_device(struct device *dev, · line 489

Quoted 10 lines
drivers/devfreq/devfreq.c +4 -3
@@ -483,9 +483,10 @@ 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->profile->max_state,
-						GFP_KERNEL);
+	devfreq->time_in_state = devm_kzalloc(dev,
+					sizeof(*(devfreq->time_in_state)) *
+					devfreq->profile->max_state,
+					GFP_KERNEL);

We could use devm_kcalloc() here too.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation