Skip to content

Commit

Permalink
can: mcp25xxfd: mcp25xxfd_ring_free(): fix memory leak during cleanup
Browse files Browse the repository at this point in the history
This loop doesn't free the first element of the array.  The "i > 0" has
to be changed to "i >= 0".

Fixes: 55e5b97 ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200923112752.GA1473821@mwanda
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Dan Carpenter authored and Marc Kleine-Budde committed Sep 30, 2020
1 parent f5b84de commit 8cffc6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8cffc6f

Please sign in to comment.