Re: [UPDATE][PATCH v3 1/2] cpufreq: intel_pstate: Allow enable/disable energy efficiency

From: Peter Zijlstra
Date: Fri Jun 26 2020 - 06:23:35 EST


On Fri, Jun 26, 2020 at 10:49:03AM +0200, Borislav Petkov wrote:
> On Thu, Jun 25, 2020 at 03:49:31PM -0700, Srinivas Pandruvada wrote:
> > +static ssize_t store_energy_efficiency_enable(struct kobject *a,
> > + struct kobj_attribute *b,
> > + const char *buf, size_t count)
> > +{
> > + u64 power_ctl;
> > + u32 input;
> > + int ret;
> > +
> > + ret = kstrtouint(buf, 10, &input);
> > + if (ret)
> > + return ret;
> > +
> > + mutex_lock(&intel_pstate_driver_lock);
> > + rdmsrl(MSR_IA32_POWER_CTL, power_ctl);
> > + if (input)
>
> This is too lax - it will be enabled for any !0 value. Please accept
> only 0 and 1.

kstrtobool() ftw