]> www.infradead.org Git - users/dwmw2/linux.git/commit
tools/power x86_energy_perf_policy: Fix argument parsing
authorZephaniah E. Loss-Cutler-Hull <zephaniah@gmail.com>
Sat, 9 Feb 2019 13:25:48 +0000 (05:25 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Sep 2019 05:18:42 +0000 (07:18 +0200)
commitcaab8b8b3acafd7406ba21707a46a5165d6eaaee
tree3caef9399e7a4528cc26c10298feafebe4fe9ca4
parentedf8ba32bc2bf2f5a3a794a326fc3de110809920
tools/power x86_energy_perf_policy: Fix argument parsing

[ Upstream commit 03531482402a2bc4ab93cf6dde46833775e035e9 ]

The -w argument in x86_energy_perf_policy currently triggers an
unconditional segfault.

This is because the argument string reads: "+a:c:dD:E:e:f:m:M:rt:u:vw" and
yet the argument handler expects an argument.

When parse_optarg_string is called with a null argument, we then proceed to
crash in strncmp, not horribly friendly.

The man page describes -w as taking an argument, the long form
(--hwp-window) is correctly marked as taking a required argument, and the
code expects it.

As such, this patch simply marks the short form (-w) as requiring an
argument.

Signed-off-by: Zephaniah E. Loss-Cutler-Hull <zephaniah@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c