[dpdk-stable] [dpdk-dev] [PATCH v1] examples/vm_power_manager: fix overflowed return value
Hunt, David
david.hunt at intel.com
Fri Apr 26 15:50:23 CEST 2019
On 26/4/2019 11:29 AM, Burakov, Anatoly wrote:
> On 26-Apr-19 9:44 AM, David Hunt wrote:
>> 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 at dpdk.org
>> Signed-off-by: David Hunt <david.hunt at 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;
>
> It should probably be the other way around - multiply first, then
> clamp. Also, please use RTE_MIN.
>
>> if (ratio < ci->branch_ratio_threshold)
>> power_manager_scale_core_min(core);
>>
Anatoly and myself have spendt some time analysing the coverity issue
just now, and we have come to the conclusion that it's a false positive.
We also think it may be an issue with coverity, so for the moment I'll
mark the coverity issue as a false positive.
More information about the stable
mailing list