Skip to content

Commit

Permalink
can: at91_can: fix use after free of priv
Browse files Browse the repository at this point in the history
The priv is part of the memory allocated by alloc_candev().
This patch moved the free it after last usage of priv.

While there convert all free_netdev() to free_candev() (which is currently
just a wrapper around free_netdev()) to be symetrically with the allocation
via alloc_candev().

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Marc Kleine-Budde authored and David S. Miller committed Oct 24, 2010
1 parent 8a0e0a4 commit 759a6c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/can/at91_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ static int __init at91_can_probe(struct platform_device *pdev)
return 0;

exit_free:
free_netdev(dev);
free_candev(dev);
exit_iounmap:
iounmap(addr);
exit_release:
Expand All @@ -1122,15 +1122,15 @@ static int __devexit at91_can_remove(struct platform_device *pdev)

platform_set_drvdata(pdev, NULL);

free_netdev(dev);

iounmap(priv->reg_base);

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));

clk_put(priv->clk);

free_candev(dev);

return 0;
}

Expand Down

0 comments on commit 759a6c7

Please sign in to comment.