Skip to content

Commit caab8b8

Browse files
Zephaniah E. Loss-Cutler-Hullgregkh
authored andcommitted
tools/power x86_energy_perf_policy: Fix argument parsing
[ Upstream commit 0353148 ] 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>
1 parent edf8ba3 commit caab8b8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ void cmdline(int argc, char **argv)
545545

546546
progname = argv[0];
547547

548-
while ((opt = getopt_long_only(argc, argv, "+a:c:dD:E:e:f:m:M:rt:u:vw",
548+
while ((opt = getopt_long_only(argc, argv, "+a:c:dD:E:e:f:m:M:rt:u:vw:",
549549
long_options, &option_index)) != -1) {
550550
switch (opt) {
551551
case 'a':

0 commit comments

Comments
 (0)