Skip to contentSkip to conversation

perf tools: delay_secs safety

PATCH In review Tim Blechmann 1 participant 2 messages Oct 17, 2009 – Oct 19, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: delay_secs safety

add delay_secs sanity check to handle_keypress, fixes a division by zero crash.

---
 tools/perf/builtin-top.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +2 -0
index 2d8806b..cc66286 100644
@@ -663,6 +663,8 @@ static void handle_keypress(int c)
 	switch (c) {
 		case 'd':
 			prompt_integer(&delay_secs, "Enter display delay");
+			if (delay_secs < 1)
+				delay_secs = 1;
 			break;
 		case 'e':
 			prompt_integer(&print_entries, "Enter display entries (lines)");
#1 lore raw

[tip:perf/urgent] perf top: Fix --delay_secs 0 division by zero

Commit-ID:  dc79959aaf80e518741657a702fa2727c86c1189
Gitweb:     http://git.kernel.org/tip/dc79959aaf80e518741657a702fa2727c86c1189
Author:     Tim Blechmann <[email protected]>
AuthorDate: Sat, 17 Oct 2009 18:08:29 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 19 Oct 2009 09:52:39 +0200

perf top: Fix --delay_secs 0 division by zero

Add delay_secs sanity check to handle_keypress, this fixes a division by zero crash.

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-top.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/builtin-top.c +2 -0
index 37512e9..a1b1d10 100644
@@ -686,6 +686,8 @@ static void handle_keypress(int c)
 	switch (c) {
 		case 'd':
 			prompt_integer(&delay_secs, "Enter display delay");
+			if (delay_secs < 1)
+				delay_secs = 1;
 			break;
 		case 'e':
 			prompt_integer(&print_entries, "Enter display entries (lines)");