Skip to contentSkip to conversation

can: mcp25xxfd: fix a leak in mcp25xxfd_ring_free()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 23, 2020

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

PATCH 1/1 can: mcp25xxfd: fix a leak in mcp25xxfd_ring_free()

This loop doesn't free the first element of the array. The "i > 0" has to be changed to "i >= 0".

Fixes 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
---
 drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +1 -1
index bd2ba981ae36..7e094afaac04 100644
@@ -377,7 +377,7 @@ static void mcp25xxfd_ring_free(struct mcp25xxfd_priv *priv)
 {
 	int i;
 
-	for (i = ARRAY_SIZE(priv->rx) - 1; i > 0; i--) {
+	for (i = ARRAY_SIZE(priv->rx) - 1; i >= 0; i--) {
 		kfree(priv->rx[i]);
 		priv->rx[i] = NULL;
 	}
Signature · 1 line
2.28.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Dan Carpenter

This loop doesn't free the first element of the array. The "i > 0" has to be changed to "i >= 0".

Fixes 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")

Applied to linux-can-next

Tnx,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |