@@ -166,11 +166,11 @@ static int set_freq_table(struct devfreq *devfreq)
count = dev_pm_opp_get_opp_count(devfreq->dev.parent);
if (count <= 0)
return -EINVAL;
profile->max_state = count;
- profile->freq_table = devm_kcalloc(devfreq->dev.parent,
+ profile->freq_table = devm_kcalloc(&devfreq->dev,
profile->max_state,
sizeof(*profile->freq_table),
GFP_KERNEL);
if (!profile->freq_table) {
profile->max_state = 0;
@@ -178,11 +178,10 @@ static int set_freq_table(struct devfreq *devfreq)
}
for (i = 0, freq = 0; i < profile->max_state; i++, freq++) {
opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq);
if (IS_ERR(opp)) {
- devm_kfree(devfreq->dev.parent, profile->freq_table);
profile->max_state = 0;
return PTR_ERR(opp);
}
dev_pm_opp_put(opp);
profile->freq_table[i] = freq;
In theory a driver can call devfreq_add_device, get an error in return and still probe succesfuly. If this happens the freq_table allocated by set_freq_table is effectively leaked. Now that device_initialize is called early inside devfreq_add_device we can use devm on devfreq->dev inside set_freq_table instead. Since that's always freed if devfreq_add_device fails there is no need to devm_kfree on any path. Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com> --- drivers/devfreq/devfreq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)