Skip to content

Commit 3e1d7fb

Browse files
committed
PM / devfreq: devm_kzalloc to have dev pointer more precisely
devm_kzalloc of devfreq's statistics data structure has been using its parent device as the dev allocated for. If a device's devfreq is disabled in run-time, such allocated memory won't be freed. Desginating more precisely with the devfreq device pointer fixes the issue. Signed-off-by: MyungJoo Ham <[email protected]>
1 parent 33688ab commit 3e1d7fb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/devfreq/devfreq.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,6 @@ struct devfreq *devfreq_add_device(struct device *dev,
561561
mutex_lock(&devfreq->lock);
562562
}
563563

564-
devfreq->trans_table = devm_kzalloc(dev, sizeof(unsigned int) *
565-
devfreq->profile->max_state *
566-
devfreq->profile->max_state,
567-
GFP_KERNEL);
568-
devfreq->time_in_state = devm_kzalloc(dev, sizeof(unsigned long) *
569-
devfreq->profile->max_state,
570-
GFP_KERNEL);
571-
devfreq->last_stat_updated = jiffies;
572-
573564
dev_set_name(&devfreq->dev, "%s", dev_name(dev));
574565
err = device_register(&devfreq->dev);
575566
if (err) {
@@ -578,6 +569,15 @@ struct devfreq *devfreq_add_device(struct device *dev,
578569
goto err_out;
579570
}
580571

572+
devfreq->trans_table = devm_kzalloc(&devfreq->dev, sizeof(unsigned int) *
573+
devfreq->profile->max_state *
574+
devfreq->profile->max_state,
575+
GFP_KERNEL);
576+
devfreq->time_in_state = devm_kzalloc(&devfreq->dev, sizeof(unsigned long) *
577+
devfreq->profile->max_state,
578+
GFP_KERNEL);
579+
devfreq->last_stat_updated = jiffies;
580+
581581
srcu_init_notifier_head(&devfreq->transition_notifier_list);
582582

583583
mutex_unlock(&devfreq->lock);

0 commit comments

Comments
 (0)