@@ -677,10 +677,15 @@ struct devfreq *devfreq_add_device(struct device *dev,
if (err) {
put_device(&devfreq->dev);
goto err_out;
}
+ /* Add to global list of devfreq instances */
+ mutex_lock(&devfreq_list_lock);
+ list_add(&devfreq->node, &devfreq_list);
+ mutex_unlock(&devfreq_list_lock);
+
devfreq->trans_table = devm_kzalloc(&devfreq->dev,
array3_size(sizeof(unsigned int),
devfreq->profile->max_state,
devfreq->profile->max_state),
GFP_KERNEL);
@@ -719,12 +724,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
dev_err(dev, "%s: Unable to start governor for the device\n",
__func__);
goto err_init;
}
- list_add(&devfreq->node, &devfreq_list);
-
mutex_unlock(&devfreq_list_lock);
return devfreq;
err_init:
After the devfreq->dev is registered all error cleanup paths call devfreq_dev_release which fails if the devfreq instance is not in the global devfreq_list. Fix by adding to the list immediately after registration. Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com> --- drivers/devfreq/devfreq.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) Alternatively we could make devfreq_dev_release accept devfreq instance not in the list.