Skip to content

Commit e10a35a

Browse files
dangowrtdavem330
authored andcommitted
net: ethernet: mtk_eth_soc: fix uninitialized variable
Variable dma_addr in function mtk_poll_rx can be uninitialized on some of the error paths. In practise this doesn't matter, even random data present in uninitialized stack memory can safely be used in the way it happens in the error path. However, in order to make Smatch happy make sure the variable is always initialized. Signed-off-by: Daniel Golle <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c821a88 commit e10a35a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,11 +2005,11 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
20052005
u8 *data, *new_data;
20062006
struct mtk_rx_dma_v2 *rxd, trxd;
20072007
int done = 0, bytes = 0;
2008+
dma_addr_t dma_addr = DMA_MAPPING_ERROR;
20082009

20092010
while (done < budget) {
20102011
unsigned int pktlen, *rxdcsum;
20112012
struct net_device *netdev;
2012-
dma_addr_t dma_addr;
20132013
u32 hash, reason;
20142014
int mac = 0;
20152015

@@ -2186,7 +2186,8 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
21862186
else
21872187
rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size);
21882188

2189-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_36BIT_DMA))
2189+
if (MTK_HAS_CAPS(eth->soc->caps, MTK_36BIT_DMA) &&
2190+
likely(dma_addr != DMA_MAPPING_ERROR))
21902191
rxd->rxd2 |= RX_DMA_PREP_ADDR64(dma_addr);
21912192

21922193
ring->calc_idx = idx;

0 commit comments

Comments
 (0)