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-next>] [day] [month] [year] [list]
Message-ID: <APAAJwCGDWnQvuJmRuA5r4pv.1.1603677021468.Hmail.bernard@vivo.com>
Date:   Mon, 26 Oct 2020 09:50:21 +0800 (GMT+08:00)
From:   Bernard <bernard@...o.com>
To:     Lukasz Luba <lukasz.luba@....com>, Zhang Rui <rui.zhang@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Amit Kucheria <amitk@...nel.org>, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     opensource.kernel@...o.com, Bernard Zhao <bernard@...o.com>
Subject: [Resend][PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp

Struct power_allocator_params element allocated_tzp is only used
in unbind to kfree the kzalloc space.
Maybe we don’t have to need this member to mark, also, kfree will
handle NULL point, there is no risk.
This change is to make the code run a bit fast.

Signed-off-by: Bernard Zhao <bernard@...o.com>
---
 drivers/thermal/gov_power_allocator.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 5cb518d8f156..e4672a94e6b1 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -51,8 +51,6 @@ static inline s64 div_frac(s64 x, s64 y)
 
 /**
  * struct power_allocator_params - parameters for the power allocator governor
- * @allocated_tzp:	whether we have allocated tzp for this thermal zone and
- *			it needs to be freed on unbind
  * @err_integral:	accumulated error in the PID controller.
  * @prev_err:	error in the previous iteration of the PID controller.
  *		Used to calculate the derivative term.
@@ -65,7 +63,6 @@ static inline s64 div_frac(s64 x, s64 y)
  *					controlling for.
  */
 struct power_allocator_params {
-	bool allocated_tzp;
 	s64 err_integral;
 	s32 prev_err;
 	int trip_switch_on;
@@ -556,8 +553,6 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
 			ret = -ENOMEM;
 			goto free_params;
 		}
-
-		params->allocated_tzp = true;
 	}
 
 	if (!tz->tzp->sustainable_power)
@@ -593,10 +588,8 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
 
 	dev_dbg(&tz->device, "Unbinding from thermal zone %d\n", tz->id);
 
-	if (params->allocated_tzp) {
-		kfree(tz->tzp);
-		tz->tzp = NULL;
-	}
+	kfree(tz->tzp);
+	tz->tzp = NULL;
 
 	kfree(tz->governor_data);
 	tz->governor_data = NULL;
-- 
2.28.0



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ