Skip to contentSkip to conversation

net: ep93xx_eth: fix mismatch of request_mem_region in remove

PATCH Applied Chuhong Yuan 2 participants 2 messages Nov 14, 2019 – Nov 15, 2019

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

PATCH 1/1 net: ep93xx_eth: fix mismatch of request_mem_region in remove

The driver calls release_resource in remove to match request_mem_region in probe, which is incorrect.
Fix it by using the right one, release_mem_region.

---
 drivers/net/ethernet/cirrus/ep93xx_eth.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/cirrus/ep93xx_eth.c +3 -2
index f1a0c4dceda0..f37c9a08c4cf 100644
@@ -763,6 +763,7 @@ static int ep93xx_eth_remove(struct platform_device *pdev)
 {
 	struct net_device *dev;
 	struct ep93xx_priv *ep;
+	struct resource *mem;
 
 	dev = platform_get_drvdata(pdev);
 	if (dev == NULL)
@@ -778,8 +779,8 @@ static int ep93xx_eth_remove(struct platform_device *pdev)
 		iounmap(ep->base_addr);
 
 	if (ep->res != NULL) {
-		release_resource(ep->res);
-		kfree(ep->res);
+		mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		release_mem_region(mem->start, resource_size(mem));
 	}
 
 	free_netdev(dev);
Signature · 1 line
2.23.0
maintainer Applied
#1 lore raw

From: Chuhong Yuan <[email protected]>
Date: Thu, 14 Nov 2019 23:43:24 +0800

Quoted 5 lines

The driver calls release_resource in remove to match request_mem_region in probe, which is incorrect.
Fix it by using the right one, release_mem_region.

Applied, thanks.

It's a shame that you can't just pass in the thing you got back from request_mem_region() to free it. And honestly the only thing that makes calling release_region() wrong is that release_region() doesn't free up the region object after unlinking it from the tree.