From 4228c81b3fc97c687d00a7c3c57ba0d63a959bb7 Mon Sep 17 00:00:00 2001 From: Minggui Cao Date: Thu, 18 Oct 2018 14:45:34 +0800 Subject: [PATCH] DM: compare unsigned numbers to avoid overflow. compare the two unsigned numbers to avoid delta calculation overflow. It could happen during UOS warm root, which can trigger a "fake" interrupt storm. Tracked-On: #1476 Signed-off-by: Minggui Cao Acked-by: Anthony Xu --- devicemodel/core/monitor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devicemodel/core/monitor.c b/devicemodel/core/monitor.c index 9240fa2e4..26afb48b5 100644 --- a/devicemodel/core/monitor.c +++ b/devicemodel/core/monitor.c @@ -121,6 +121,10 @@ static void *intr_storm_monitor_thread(void *arg) if (hdr->buffer[i] != intr_cnt_buf[i]) continue; + /* avoid delta overflow */ + if (hdr->buffer[i + 1] < intr_cnt_buf[i + 1]) + continue; + delta = hdr->buffer[i + 1] - intr_cnt_buf[i + 1]; if (delta > INTR_STORM_THRESHOLD) { #ifdef INTR_MONITOR_DBG