DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] examples/vm_power_manager: fix overflowed return value
@ 2019-04-26  8:44 David Hunt
  2019-04-26  8:44 ` David Hunt
  2019-04-26 10:29 ` Burakov, Anatoly
  0 siblings, 2 replies; 12+ messages in thread
From: David Hunt @ 2019-04-26  8:44 UTC (permalink / raw)
  To: dev; +Cc: david.hunt, stable

Coverity complains about the return of a value that may
possibly overflow because of a multiply. Limit the value
so it cannot overflow.

Coverity issue: 337677
Fixes: 4b1a631b8a ("examples/vm_power: add oob monitoring functions")
CC: stable@dpdk.org
Signed-off-by: David Hunt <david.hunt@intel.com>
---
 examples/vm_power_manager/oob_monitor_x86.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/examples/vm_power_manager/oob_monitor_x86.c b/examples/vm_power_manager/oob_monitor_x86.c
index ebd96b205..2074eec1e 100644
--- a/examples/vm_power_manager/oob_monitor_x86.c
+++ b/examples/vm_power_manager/oob_monitor_x86.c
@@ -99,7 +99,10 @@ apply_policy(int core)
 		return -1.0;
 	}
 
-	ratio = (float)miss_diff * (float)100 / (float)hits_diff;
+	ratio = (float)miss_diff / (float)hits_diff;
+	if (ratio > 1.0)
+		ratio = 1.0;
+	ratio *= 100.0f;
 
 	if (ratio < ci->branch_ratio_threshold)
 		power_manager_scale_core_min(core);
-- 
2.17.1

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

end of thread, other threads:[~2019-04-26 13:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26  8:44 [dpdk-dev] [PATCH v1] examples/vm_power_manager: fix overflowed return value David Hunt
2019-04-26  8:44 ` David Hunt
2019-04-26 10:29 ` Burakov, Anatoly
2019-04-26 10:29   ` Burakov, Anatoly
2019-04-26 11:14   ` Hunt, David
2019-04-26 11:14     ` Hunt, David
2019-04-26 12:03     ` Burakov, Anatoly
2019-04-26 12:03       ` Burakov, Anatoly
2019-04-26 12:35       ` Burakov, Anatoly
2019-04-26 12:35         ` Burakov, Anatoly
2019-04-26 13:50   ` Hunt, David
2019-04-26 13:50     ` Hunt, David

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).