diff mbox series

[1/6] PM / devfreq: Free devfreq upon set_freq_table error

Message ID 20180424223521.28193-2-bjorn.andersson@linaro.org
State New
Headers show
Series Misc devfreq_add_device() fixes | expand

Commit Message

Bjorn Andersson April 24, 2018, 10:35 p.m. UTC
When set_freq_table() fails we must still free the previously allocated
devfreq context, so jump to the correct label for this. Also when this
happens devfreq will always be non-NULL, so drop the unnecessary
conditional.

Also destroy the devfreq mutex as we're cleaning up the devfreq object.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

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

-- 
2.16.2
diff mbox series

Patch

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 2067cd229ce3..30a672397ff0 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -597,7 +597,7 @@  struct devfreq *devfreq_add_device(struct device *dev,
 		mutex_unlock(&devfreq->lock);
 		err = set_freq_table(devfreq);
 		if (err < 0)
-			goto err_out;
+			goto err_dev;
 		mutex_lock(&devfreq->lock);
 	}
 
@@ -669,8 +669,8 @@  struct devfreq *devfreq_add_device(struct device *dev,
 
 	device_unregister(&devfreq->dev);
 err_dev:
-	if (devfreq)
-		kfree(devfreq);
+	mutex_destroy(&devfreq->lock);
+	kfree(devfreq);
 err_out:
 	return ERR_PTR(err);
 }