public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: fix possible divide-by-zero in perf_swevent_overflow()
@ 2010-08-26 12:07 Dongdong Deng
  2010-08-26 12:12 ` Peter Zijlstra
  0 siblings, 1 reply; 9+ messages in thread
From: Dongdong Deng @ 2010-08-26 12:07 UTC (permalink / raw)
  To: mingo, a.p.zijlstra, fweisbec; +Cc: acme, paulus, linux-kernel

The event->hw.last_period is possible to zero, thus it will
cause divide_by_zero later in perf_swevent_set_period().

This patch checks event->hw.last_period before invoke
perf_swevent_set_period() and replaces "event->hw" with "hwc".

Signed-off-by: Dongdong Deng <dongdong.deng@windriver.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
---
 kernel/perf_event.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 403d180..ccba741 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -4050,8 +4050,8 @@ static void perf_swevent_overflow(struct perf_event *event, u64 overflow,
 	struct hw_perf_event *hwc = &event->hw;
 	int throttle = 0;
 
-	data->period = event->hw.last_period;
-	if (!overflow)
+	data->period = hwc->last_period;
+	if (!overflow && hwc->last_period)
 		overflow = perf_swevent_set_period(event);
 
 	if (hwc->interrupts == MAX_INTERRUPTS)
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-10-25  5:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-26 12:07 [PATCH] perf: fix possible divide-by-zero in perf_swevent_overflow() Dongdong Deng
2010-08-26 12:12 ` Peter Zijlstra
2010-08-26 12:36   ` DDD
2010-08-26 12:58     ` Peter Zijlstra
2010-08-27 12:21       ` DDD
2010-08-27 12:50         ` Peter Zijlstra
2010-08-27 13:19           ` DDD
2010-08-27 13:37             ` Frederic Weisbecker
2010-10-25  5:58               ` DDD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox