All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: linux-pm@vger.kernel.org
Cc: "Zephaniah E. Loss-Cutler-Hull" <zephaniah@gmail.com>,
	Len Brown <len.brown@intel.com>
Subject: [PATCH 04/19] tools/power x86_energy_perf_policy: Fix argument parsing
Date: Sat, 31 Aug 2019 15:34:43 -0400	[thread overview]
Message-ID: <03531482402a2bc4ab93cf6dde46833775e035e9.1567277326.git.len.brown@intel.com> (raw)
In-Reply-To: <adb8049097a9ec4acd09fbd3aa8636199a78df8a.1567277326.git.len.brown@intel.com>

From: "Zephaniah E. Loss-Cutler-Hull" <zephaniah@gmail.com>

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>
---
 tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
index 7663abef51e9..3fe1eed900d4 100644
--- a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
+++ b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
@@ -545,7 +545,7 @@ void cmdline(int argc, char **argv)
 
 	progname = argv[0];
 
-	while ((opt = getopt_long_only(argc, argv, "+a:c:dD:E:e:f:m:M:rt:u:vw",
+	while ((opt = getopt_long_only(argc, argv, "+a:c:dD:E:e:f:m:M:rt:u:vw:",
 				long_options, &option_index)) != -1) {
 		switch (opt) {
 		case 'a':
-- 
2.20.1


  parent reply	other threads:[~2019-08-31 19:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-31 19:34 turbostat 19.08.31 is available Len Brown
2019-08-31 19:34 ` [PATCH 01/19] tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2 Len Brown
2019-08-31 19:34   ` [PATCH 02/19] tools/power/x86: Enable compiler optimisations and Fortify by default Len Brown
2019-08-31 19:34   ` [PATCH 03/19] tools/power: Fix typo in man page Len Brown
2019-08-31 19:34   ` Len Brown [this message]
2019-08-31 19:34   ` [PATCH 05/19] tools/power turbostat: remove duplicate pc10 column Len Brown
2019-08-31 19:34   ` [PATCH 06/19] tools/power turbostat: Make interval calculation per thread to reduce jitter Len Brown
2019-08-31 19:34   ` [PATCH 07/19] tools/power turbostat: fix leak of file descriptor on error return path Len Brown
2019-08-31 19:34   ` [PATCH 08/19] tools/power turbostat: fix file descriptor leaks Len Brown
2019-08-31 19:34   ` [PATCH 09/19] tools/power turbostat: fix buffer overrun Len Brown
2019-08-31 19:34   ` [PATCH 10/19] tools/power turbostat: add Jacobsville support Len Brown
2019-08-31 19:34   ` [PATCH 11/19] tools/power turbostat: Fix Haswell Core systems Len Brown
2019-08-31 19:34   ` [PATCH 12/19] tools/power turbostat: rename has_hsw_msrs() Len Brown
2019-08-31 19:34   ` [PATCH 13/19] tools/power turbostat: Add Ice Lake NNPI support Len Brown
2019-08-31 19:34   ` [PATCH 14/19] tools/power turbostat: read from pipes too Len Brown
2019-08-31 19:34   ` [PATCH 15/19] tools/power turbostat: do not enforce 1ms Len Brown
2019-08-31 19:34   ` [PATCH 16/19] tools/power turbostat: Fix CPU%C1 display value Len Brown
2019-08-31 19:34   ` [PATCH 17/19] tools/power turbostat: Fix caller parameter of get_tdp_amd() Len Brown
2019-08-31 19:34   ` [PATCH 18/19] tools/power turbostat: Add support for Hygon Fam 18h (Dhyana) RAPL Len Brown
2019-08-31 19:34   ` [PATCH 19/19] tools/power turbostat: update version number Len Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03531482402a2bc4ab93cf6dde46833775e035e9.1567277326.git.len.brown@intel.com \
    --to=lenb@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=zephaniah@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.