[PATCH] cpufreq: arm_scmi: Fix error path when allocation failed

Subsystems: cpu frequency scaling framework, system control & power/management interface (scpi/scmi) message protocol drivers, the rest

STALE1842d

3 messages, 2 authors, 2021-08-03 · open the first message on its own page

[PATCH] cpufreq: arm_scmi: Fix error path when allocation failed

From: Lukasz Luba <lukasz.luba@arm.com>
Date: 2021-08-02 20:46:26

Print warning and return an error which would stop the initialization
when cpumask allocation failed.

Fixes: 80a064dbd556 ("scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/cpufreq/scmi-cpufreq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index ec9a87ca2dbb..b159123e68fd 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -133,8 +133,10 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
 		return -ENODEV;
 	}
 
-	if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL))
-		ret = -ENOMEM;
+	if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL)) {
+		dev_warn(cpu_dev, "failed to allocate cpumask\n");
+		return -ENOMEM;
+	}
 
 	/* Obtain CPUs that share SCMI performance controls */
 	ret = scmi_get_sharing_cpus(cpu_dev, policy->cpus);
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] cpufreq: arm_scmi: Fix error path when allocation failed

From: Viresh Kumar <viresh.kumar@linaro.org>
Date: 2021-08-03 04:34:56

On 02-08-21, 21:45, Lukasz Luba wrote:
quoted hunk
Print warning and return an error which would stop the initialization
when cpumask allocation failed.

Fixes: 80a064dbd556 ("scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/cpufreq/scmi-cpufreq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index ec9a87ca2dbb..b159123e68fd 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -133,8 +133,10 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
 		return -ENODEV;
 	}
 
-	if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL))
-		ret = -ENOMEM;
+	if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL)) {
+		dev_warn(cpu_dev, "failed to allocate cpumask\n");
We shouldn't be printing here anything I believe as the allocation
core does it for us. That's why you won't see a print message anywhere
for failed allocations.
+		return -ENOMEM;
+	}
 
 	/* Obtain CPUs that share SCMI performance controls */
 	ret = scmi_get_sharing_cpus(cpu_dev, policy->cpus);
-- 
2.17.1
-- 
viresh

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] cpufreq: arm_scmi: Fix error path when allocation failed

From: Lukasz Luba <lukasz.luba@arm.com>
Date: 2021-08-03 08:49:31

Hi Viresh,

On 8/3/21 5:34 AM, Viresh Kumar wrote:
On 02-08-21, 21:45, Lukasz Luba wrote:
quoted
Print warning and return an error which would stop the initialization
when cpumask allocation failed.

Fixes: 80a064dbd556 ("scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
  drivers/cpufreq/scmi-cpufreq.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index ec9a87ca2dbb..b159123e68fd 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -133,8 +133,10 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
  		return -ENODEV;
  	}
  
-	if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL))
-		ret = -ENOMEM;
+	if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL)) {
+		dev_warn(cpu_dev, "failed to allocate cpumask\n");
We shouldn't be printing here anything I believe as the allocation
core does it for us. That's why you won't see a print message anywhere
for failed allocations.
Thanks for the comment. Let me send the v2.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help