Skip to contentSkip to conversation

thermal: intel: powerclamp: Return -ENOMEM on allocation failure

PATCH Applied Thorsten Blum 2 participants 2 messages Nov 11 – Nov 13 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: intel: powerclamp: Return -ENOMEM on allocation failure

cpumask_set() returns success (0) if alloc_cpumask_var() fails. Return -ENOMEM instead.

Fixes ebf519710218 ("thermal: intel: powerclamp: Add two module parameters")
---
 drivers/thermal/intel/intel_powerclamp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +3 -2
index 1ffcb0a699e5..df898fc3f3e6 100644
@@ -157,9 +157,10 @@ static int cpumask_set(const char *arg, const struct kernel_param *kp)
 		goto skip_cpumask_set;
 	}
 
-	ret = alloc_cpumask_var(&new_mask, GFP_KERNEL);
-	if (!ret)
+	if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) {
+		ret = -ENOMEM;
 		goto skip_cpumask_set;
+	}
 
 	ret = bitmap_parse(arg, strlen(arg), cpumask_bits(new_mask),
 			   nr_cpumask_bits);
maintainer Applied
#1 lore raw
Quoted 18 lines · Thorsten Blum

cpumask_set() returns success (0) if alloc_cpumask_var() fails. Return -ENOMEM instead.

Fixes ebf519710218 ("thermal: intel: powerclamp: Add two module parameters")
---
 drivers/thermal/intel/intel_powerclamp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +0 -0
index 1ffcb0a699e5..df898fc3f3e6 100644
@@ -157,9 +157,10 @@ static int cpumask_set(const char *arg, const struct kernel_param *kp)
                goto skip_cpumask_set;
        }

drivers/thermal/intel/intel_powerclamp.c static int cpumask_set(const char *arg, const struct kernel_param *kp) · line 166

Quoted 10 lines
drivers/thermal/intel/intel_powerclamp.c +3 -2
 
-       ret = alloc_cpumask_var(&new_mask, GFP_KERNEL);
-       if (!ret)
+       if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) {
+               ret = -ENOMEM;
                goto skip_cpumask_set;
+       }
 
        ret = bitmap_parse(arg, strlen(arg), cpumask_bits(new_mask),
                           nr_cpumask_bits);

Applied as 7.5 material, thanks!