lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 22 Nov 2021 10:41:04 +0800 From: Huang Rui <ray.huang@....com> To: Juuso Alasuutari <juuso.alasuutari@...il.com>, "Fontenot, Nathan" <Nathan.Fontenot@....com> Cc: "Su, Jinzhou (Joe)" <Jinzhou.Su@....com>, "Du, Xiaojian" <Xiaojian.Du@....com>, "Deucher, Alexander" <Alexander.Deucher@....com>, "bp@...e.de" <bp@...e.de>, "Sharma, Deepak" <Deepak.Sharma@....com>, "ggherdovich@...e.cz" <ggherdovich@...e.cz>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>, "Limonciello, Mario" <Mario.Limonciello@....com>, "mingo@...nel.org" <mingo@...nel.org>, "peterz@...radead.org" <peterz@...radead.org>, "rafael.j.wysocki@...el.com" <rafael.j.wysocki@...el.com>, "skhan@...uxfoundation.org" <skhan@...uxfoundation.org>, "steven@...vesoftware.com" <steven@...vesoftware.com>, "viresh.kumar@...aro.org" <viresh.kumar@...aro.org>, "x86@...nel.org" <x86@...nel.org> Subject: Re: [PATCH v4 16/22] cpupower: add the function to get the sysfs value from specific table On Sat, Nov 20, 2021 at 06:19:43AM +0800, Juuso Alasuutari wrote: > On Fri, 19 Nov 2021 14:38:58 -0600, Nathan Fontenot wrote: > > On 11/19/21 4:30 AM, Huang Rui wrote: > > > Expose the helper into cpufreq header, then cpufreq driver can use this > > > function to get the sysfs value if it has any specific sysfs interfaces. > > > > > > Signed-off-by: Huang Rui <ray.huang@....com> > > > --- > > > tools/power/cpupower/lib/cpufreq.c | 21 +++++++++++++++------ > > > tools/power/cpupower/lib/cpufreq.h | 12 ++++++++++++ > > > 2 files changed, 27 insertions(+), 6 deletions(-) > > > > > > diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c > > > index c3b56db8b921..02719cc400a1 100644 > > > --- a/tools/power/cpupower/lib/cpufreq.c > > > +++ b/tools/power/cpupower/lib/cpufreq.c > > > @@ -83,20 +83,21 @@ static const char *cpufreq_value_files[MAX_CPUFREQ_VALUE_READ_FILES] = { > > > [STATS_NUM_TRANSITIONS] = "stats/total_trans" > > > }; > > > > > > - > > > -static unsigned long sysfs_cpufreq_get_one_value(unsigned int cpu, > > > - enum cpufreq_value which) > > > +unsigned long cpufreq_get_sysfs_value_from_table(unsigned int cpu, > > > + const char **table, > > > + unsigned index, > > > + unsigned size) > > > { > > > unsigned long value; > > > unsigned int len; > > > char linebuf[MAX_LINE_LEN]; > > > char *endp; > > > > > > - if (which >= MAX_CPUFREQ_VALUE_READ_FILES) > > > + if (!table && !table[index] && index >= size) > > > > Should you validate the index before accessing table[index] > > > > if (!table && index >= size && !table[index]) > > The operator is wrong as well. I believe this is what was originally intended: > > if (!table || index >= size || !table[index]) Yes, nice catch. Thanks. Updated it. Thanks, Ray
Powered by blists - more mailing lists