]> git.baikalelectronics.ru Git - kernel.git/commit
net: stmmac: Fix potential integer overflow
authorWong Vee Khee <vee.khee.wong@linux.intel.com>
Fri, 11 Jun 2021 09:02:38 +0000 (17:02 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Jun 2021 20:11:54 +0000 (13:11 -0700)
commit28896bec1286f83cfd49ff080219e1c3260d22e9
tree2b4e56399b84647003dcd5e2113ae8134a7cb765
parent0934142eded0b6016078ff315e44f545c5125219
net: stmmac: Fix potential integer overflow

The commit 95ffa90fa40d ("net: stmmac: arrange Tx tail pointer update
to stmmac_flush_tx_descriptors") introduced the following coverity
warning:-

  1. Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
     overflow_before_widen: Potentially overflowing expression
     'tx_q->cur_tx * desc_size' with type 'unsigned int' (32 bits,
     unsigned) is evaluated using 32-bit arithmetic, and then used in a
     context that expects an expression of type dma_addr_t (64 bits,
     unsigned).

Fixed this by assigning tx_tail_addr to dma_addr_t type, as dma_addr_t
datatype is decided by CONFIG_ARCH_DMA_ADDR_T_64_BIT.

Fixes: 95ffa90fa40d ("net: stmmac: arrange Tx tail pointer update to stmmac_flush_tx_descriptors")
Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac.h