Skip to contentSkip to conversation

mvpp2: use correct size for memset

PATCH Applied Arnd Bergmann 2 participants 2 messages Nov 24, 2016 – Nov 26, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mvpp2: use correct size for memset

gcc-7 detects a short memset in mvpp2, introduced in the original merge of the driver:

drivers/net/ethernet/marvell/mvpp2.c: In function 'mvpp2_cls_init':
drivers/net/ethernet/marvell/mvpp2.c:3296:2: error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]

The result seems to be that we write uninitialized data into the flow table registers, although we did not get any warning about that uninitialized data usage.

Using sizeof() lets us initialize then entire array instead.

Fixes 3f518509dedc ("ethernet: Add new driver for Marvell Armada 375 network unit")
---
 drivers/net/ethernet/marvell/mvpp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvpp2.c +1 -1
index ee857868bea5..dabc5418efcc 100644
@@ -3293,7 +3293,7 @@ static void mvpp2_cls_init(struct mvpp2 *priv)
 	mvpp2_write(priv, MVPP2_CLS_MODE_REG, MVPP2_CLS_MODE_ACTIVE_MASK);
 
 	/* Clear classifier flow table */
-	memset(&fe.data, 0, MVPP2_CLS_FLOWS_TBL_DATA_WORDS);
+	memset(&fe.data, 0, sizeof(fe.data));
 	for (index = 0; index < MVPP2_CLS_FLOWS_TBL_SIZE; index++) {
 		fe.index = index;
 		mvpp2_cls_flow_write(priv, &fe);
Signature · 1 line
2.9.0
maintainer Applied
#1 lore raw

From: Arnd Bergmann <[email protected]>
Date: Thu, 24 Nov 2016 17:28:12 +0100

Quoted 6 lines

gcc-7 detects a short memset in mvpp2, introduced in the original merge of the driver:

drivers/net/ethernet/marvell/mvpp2.c: In function 'mvpp2_cls_init':
drivers/net/ethernet/marvell/mvpp2.c:3296:2: error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]

Quoted 8 lines

The result seems to be that we write uninitialized data into the flow table registers, although we did not get any warning about that uninitialized data usage.

Using sizeof() lets us initialize then entire array instead.

Fixes 3f518509dedc ("ethernet: Add new driver for Marvell Armada 375 network unit")

Applied, thanks.