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: <20230324070807.6342-5-rui.zhang@intel.com>
Date:   Fri, 24 Mar 2023 15:08:07 +0800
From:   Zhang Rui <rui.zhang@...el.com>
To:     linux-pm@...r.kernel.org, rafael.j.wysocki@...el.com,
        daniel.lezcano@...aro.org
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH 5/5] thermal/core: Avoid unbind for thermal zones without .unbind()

The ops->bind()/unbind() callback is the only way to bind/unbind a
cooling device to/from a thermal zone.

Optimize the code to avoid trying unbind when .unbind() callback doesn't
exist.

Signed-off-by: Zhang Rui <rui.zhang@...el.com>
---
 drivers/thermal/thermal_core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 9c447f22cb39..1af36450f13e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1411,6 +1411,9 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 	}
 	list_del(&tz->node);
 
+	if (!tz->ops->unbind)
+		goto unbind_done;
+
 	/* Unbind all cdevs associated with 'this' thermal zone */
 	list_for_each_entry(cdev, &thermal_cdev_list, node) {
 		struct thermal_instance *ti;
@@ -1428,8 +1431,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 		continue;
 
 unbind:
-		if (tz->ops->unbind)
-			tz->ops->unbind(tz, cdev);
+		tz->ops->unbind(tz, cdev);
 
 		/*
 		 * The thermal instances for current thermal zone has been
@@ -1441,6 +1443,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 		mutex_unlock(&cdev->lock);
 	}
 
+unbind_done:
 	mutex_unlock(&thermal_list_lock);
 
 	cancel_delayed_work_sync(&tz->poll_queue);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ