From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] PM / devfreq: Use the device release function for cleanup
Date: Tue, 24 Apr 2018 15:35:17 -0700 [thread overview]
Message-ID: <20180424223521.28193-3-bjorn.andersson@linaro.org> (raw)
In-Reply-To: <20180424223521.28193-1-bjorn.andersson@linaro.org>
Removing the devfreq from the devfreq_list before calling unregister
causes the device's release function to not find the devfreq and as such
bails from the release function, resulting in the following log
entries if an invalid governor is specified.
ufshcd-qcom 624000.ufshc: devfreq_add_device: Unable to find governor for the device
devfreq devfreq0: releasing devfreq which doesn't exist
Drop the removal of devfreq from the list.
As the release function will end by freeing the devfreq context we have
to skip the freeing of this in our error handler, and hence need to pull
in the device_unregister() calls.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
drivers/devfreq/devfreq.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 30a672397ff0..d5b278b8f20e 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -647,8 +647,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
if (IS_ERR(governor)) {
dev_err(dev, "%s: Unable to find governor for the device\n",
__func__);
+ mutex_unlock(&devfreq_list_lock);
+ device_unregister(&devfreq->dev);
err = PTR_ERR(governor);
- goto err_init;
+ goto err_out;
}
devfreq->governor = governor;
@@ -657,17 +659,14 @@ struct devfreq *devfreq_add_device(struct device *dev,
if (err) {
dev_err(dev, "%s: Unable to start governor for the device\n",
__func__);
- goto err_init;
+ mutex_unlock(&devfreq_list_lock);
+ device_unregister(&devfreq->dev);
+ goto err_out;
}
mutex_unlock(&devfreq_list_lock);
return devfreq;
-err_init:
- list_del(&devfreq->node);
- mutex_unlock(&devfreq_list_lock);
-
- device_unregister(&devfreq->dev);
err_dev:
mutex_destroy(&devfreq->lock);
kfree(devfreq);
--
2.16.2
next prev parent reply other threads:[~2018-04-24 22:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-24 22:35 [PATCH 0/6] Misc devfreq_add_device() fixes Bjorn Andersson
2018-04-24 22:35 ` [PATCH 1/6] PM / devfreq: Free devfreq upon set_freq_table error Bjorn Andersson
2018-04-24 22:35 ` Bjorn Andersson [this message]
2018-04-24 22:35 ` [PATCH 3/6] PM / devfreq: Reorder devfreq_add_device() Bjorn Andersson
2018-04-24 22:35 ` [PATCH 4/6] PM / devfreq: Remove unnecessary locking Bjorn Andersson
2018-04-24 22:35 ` [PATCH 5/6] PM / devfreq: Use put_device() on device_register error Bjorn Andersson
2018-04-24 22:35 ` [PATCH 6/6] PM / devfreq: Reject client provided freq_table Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180424223521.28193-3-bjorn.andersson@linaro.org \
--to=bjorn.andersson@linaro.org \
--cc=cw00.choi@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®