diff mbox series

[net-next,v1,1/1] net: stmmac: Fix potential integer overflow

Message ID 20210611090238.1157557-1-vee.khee.wong@linux.intel.com (mailing list archive)
State Accepted
Commit 52e597d3e2e6e5bfce47559eb22b955ac17b3826
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v1,1/1] net: stmmac: Fix potential integer overflow | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers fail 1 blamed authors not CCed: boon.leong.ong@intel.com; 1 maintainers not CCed: boon.leong.ong@intel.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 20 this patch: 20
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
netdev/header_inline success Link

Commit Message

Wong Vee Khee June 11, 2021, 9:02 a.m. UTC
The commit d96febedfde2 ("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: d96febedfde2 ("net: stmmac: arrange Tx tail pointer update to stmmac_flush_tx_descriptors")
Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 11, 2021, 8:20 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Fri, 11 Jun 2021 17:02:38 +0800 you wrote:
> The commit d96febedfde2 ("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).
> 
> [...]

Here is the summary with links:
  - [net-next,v1,1/1] net: stmmac: Fix potential integer overflow
    https://git.kernel.org/netdev/net-next/c/52e597d3e2e6

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index fd7212afc543..6655cb8e24cf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -75,7 +75,7 @@  struct stmmac_tx_queue {
 	unsigned int cur_tx;
 	unsigned int dirty_tx;
 	dma_addr_t dma_tx_phy;
-	u32 tx_tail_addr;
+	dma_addr_t tx_tail_addr;
 	u32 mss;
 };