]> xenbits.xensource.com Git - xen.git/commitdiff
x86/pmstat: correct get_cpufreq_para()'s error return value
authorJan Beulich <jbeulich@suse.com>
Thu, 27 Mar 2025 14:26:52 +0000 (15:26 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 27 Mar 2025 14:26:52 +0000 (15:26 +0100)
copy_to_guest() returns the number of bytes not copied; that's not what
the function should return to its caller though. Convert to returning
-EFAULT instead.

Fixes: 7542c4ff00f2 ("Add user PM control interface")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 855337ca4947508ffca23393e291c54b5307cc9a
master date: 2025-03-27 12:22:06 +0100

xen/drivers/acpi/pmstat.c

index 803971bdb0631bd29ec07132fea245f5eb0d4268..9e82f06ee1b9de6a2c30d2176dbf83c43cff3a26 100644 (file)
@@ -225,7 +225,7 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
                        affected_cpus, op->u.get_para.cpu_num);
     xfree(affected_cpus);
     if ( ret )
-        return ret;
+        return -EFAULT;
 
     if ( !(scaling_available_frequencies =
            xzalloc_array(uint32_t, op->u.get_para.freq_num)) )
@@ -237,7 +237,7 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
                    scaling_available_frequencies, op->u.get_para.freq_num);
     xfree(scaling_available_frequencies);
     if ( ret )
-        return ret;
+        return -EFAULT;
 
     op->u.get_para.cpuinfo_cur_freq =
         cpufreq_driver.get ? alternative_call(cpufreq_driver.get, op->cpuid)
@@ -273,7 +273,7 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
                             gov_num * CPUFREQ_NAME_LEN);
         xfree(scaling_available_governors);
         if ( ret )
-            return ret;
+            return -EFAULT;
 
         op->u.get_para.u.s.scaling_cur_freq = policy->cur;
         op->u.get_para.u.s.scaling_max_freq = policy->max;