lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180424223521.28193-3-bjorn.andersson@linaro.org>
Date:   Tue, 24 Apr 2018 15:35:17 -0700
From:   Bjorn Andersson <bjorn.andersson@...aro.org>
To:     MyungJoo Ham <myungjoo.ham@...sung.com>,
        Kyungmin Park <kyungmin.park@...sung.com>,
        Chanwoo Choi <cw00.choi@...sung.com>
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/6] PM / devfreq: Use the device release function for cleanup

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@...aro.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ