2010-08-03 18:55:09

by Stefan Weil

[permalink] [raw]
Subject: [PATCH] davinci_emac: Fix use after free in davinci_emac_remove

free_netdev finally calls kfree which makes the contents
of ndev and priv (private data contained in ndev) invalid.

So iounmap should be called before free_netdev.

Cc: David S. Miller <[email protected]>
Cc: Chaithrika U S <[email protected]>
Cc: Sriramakrishnan <[email protected]>
Cc: Kevin Hilman <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Stefan Weil <[email protected]>
---
drivers/net/davinci_emac.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 8cc8a43..866e6b8 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -2818,8 +2818,8 @@ static int __devexit davinci_emac_remove(struct platform_device *pdev)
release_mem_region(res->start, res->end - res->start + 1);

unregister_netdev(ndev);
- free_netdev(ndev);
iounmap(priv->remap_addr);
+ free_netdev(ndev);

clk_disable(emac_clk);
clk_put(emac_clk);
--
1.5.6.5


2010-08-04 04:36:00

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] davinci_emac: Fix use after free in davinci_emac_remove

From: Stefan Weil <[email protected]>
Date: Tue, 3 Aug 2010 20:53:45 +0200

> free_netdev finally calls kfree which makes the contents
> of ndev and priv (private data contained in ndev) invalid.
>
> So iounmap should be called before free_netdev.
>
> Cc: David S. Miller <[email protected]>
> Cc: Chaithrika U S <[email protected]>
> Cc: Sriramakrishnan <[email protected]>
> Cc: Kevin Hilman <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Stefan Weil <[email protected]>

I'll apply this, thanks.