All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] powercap/drivers/dtpm: Fix a double shift bug
@ 2021-01-06  8:36 ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2021-01-06  8:36 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano; +Cc: Lukasz Luba, linux-pm, kernel-janitors

The DTPM_POWER_LIMIT_FLAG is used for test_bit() etc which take a bit
number so it should be bit 0.  But currently it's set to BIT(0) then
that is double shifted equivalent to BIT(BIT(0)).  This doesn't cause a
run time problem because it's done consistently.

Fixes: a20d0ef97abf ("powercap/drivers/dtpm: Add API for dynamic thermal power management")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/powercap/dtpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c
index 0abcc439d728..d49df0569cd4 100644
--- a/drivers/powercap/dtpm.c
+++ b/drivers/powercap/dtpm.c
@@ -24,7 +24,7 @@
 #include <linux/slab.h>
 #include <linux/mutex.h>
 
-#define DTPM_POWER_LIMIT_FLAG BIT(0)
+#define DTPM_POWER_LIMIT_FLAG 0
 
 static const char *constraint_name[] = {
 	"Instantaneous",
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread
* [PATCH 2/3] powercap/drivers/dtpm: Fix some missing unlock bugs
  2021-01-06  8:36 ` Dan Carpenter
@ 2021-01-06  8:41 ` Dan Carpenter
  -1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2021-01-06  8:41 UTC (permalink / raw)
  To: kernel-janitors

We need to unlock on these paths before returning.

Fixes: a20d0ef97abf ("powercap/drivers/dtpm: Add API for dynamic thermal power management")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/powercap/dtpm.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c
index d49df0569cd4..470a1182b868 100644
--- a/drivers/powercap/dtpm.c
+++ b/drivers/powercap/dtpm.c
@@ -147,13 +147,17 @@ static void __dtpm_add_power(struct dtpm *dtpm)
  */
 int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max)
 {
+	int ret = 0;
+
 	mutex_lock(&dtpm_lock);
 
 	if (power_min = dtpm->power_min && power_max = dtpm->power_max)
-		return 0;
+		goto unlock;
 
-	if (power_max < power_min)
-		return -EINVAL;
+	if (power_max < power_min) {
+		ret = -EINVAL;
+		goto unlock;
+	}
 
 	__dtpm_sub_power(dtpm);
 
@@ -164,9 +168,10 @@ int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max)
 
 	__dtpm_add_power(dtpm);
 
+unlock:
 	mutex_unlock(&dtpm_lock);
 
-	return 0;
+	return ret;
 }
 
 /**
@@ -187,8 +192,10 @@ int dtpm_release_zone(struct powercap_zone *pcz)
 
 	mutex_lock(&dtpm_lock);
 
-	if (!list_empty(&dtpm->children))
+	if (!list_empty(&dtpm->children)) {
+		mutex_unlock(&dtpm_lock);
 		return -EBUSY;
+	}
 
 	if (parent)
 		list_del(&dtpm->sibling);
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-01-07 17:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06  8:36 [PATCH 1/3] powercap/drivers/dtpm: Fix a double shift bug Dan Carpenter
2021-01-06  8:36 ` Dan Carpenter
2021-01-06  9:03 ` [PATCH 3/3] powercap/drivers/dtpm: Fix an IS_ERR() vs NULL check Dan Carpenter
2021-01-06  9:03   ` Dan Carpenter
2021-01-07 17:03   ` Daniel Lezcano
2021-01-07 17:03     ` Daniel Lezcano
2021-01-07 17:19     ` Rafael J. Wysocki
2021-01-07 17:19       ` Rafael J. Wysocki
2021-01-07 16:59 ` [PATCH 1/3] powercap/drivers/dtpm: Fix a double shift bug Daniel Lezcano
2021-01-07 16:59   ` Daniel Lezcano
2021-01-06  8:41 [PATCH 2/3] powercap/drivers/dtpm: Fix some missing unlock bugs Dan Carpenter
2021-01-06  8:41 ` Dan Carpenter
2021-01-07 17:01 ` Daniel Lezcano
2021-01-07 17:01   ` Daniel Lezcano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.