[dpdk-dev] net/softnic: fix integer overflow

Message ID 20171019093945.126311-1-jasvinder.singh@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jasvinder Singh Oct. 19, 2017, 9:39 a.m. UTC
  Fixed integer overflow by casting hard_rate to uint64_t type.

CID 195020 (#1 of 1): Unintentional integer overflow
(OVERFLOW_BEFORE_WIDEN)

Fixes: 8316b9816b79 ("net/softnic: support traffic management")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_tm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit Oct. 23, 2017, 6:54 p.m. UTC | #1
On 10/19/2017 2:39 AM, Jasvinder Singh wrote:
> Fixed integer overflow by casting hard_rate to uint64_t type.

Coverity Issue: 195020
> Fixes: 8316b9816b79 ("net/softnic: support traffic management")
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Ferruh Yigit Oct. 23, 2017, 7:07 p.m. UTC | #2
On 10/23/2017 11:54 AM, Ferruh Yigit wrote:
> On 10/19/2017 2:39 AM, Jasvinder Singh wrote:
>> Fixed integer overflow by casting hard_rate to uint64_t type.
> 
> Coverity Issue: 195020
>> Fixes: 8316b9816b79 ("net/softnic: support traffic management")
>>
>> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c
index 682cc4d..dbb2514 100644
--- a/drivers/net/softnic/rte_eth_softnic_tm.c
+++ b/drivers/net/softnic/rte_eth_softnic_tm.c
@@ -47,7 +47,7 @@ 
 int
 tm_params_check(struct pmd_params *params, uint32_t hard_rate)
 {
-	uint64_t hard_rate_bytes_per_sec = hard_rate * BYTES_IN_MBPS;
+	uint64_t hard_rate_bytes_per_sec = (uint64_t)hard_rate * BYTES_IN_MBPS;
 	uint32_t i;
 
 	/* rate */