Skip to contentSkip to conversation

MTD: nand: Fix release_mem_region() size

PATCH In review Thomas Fourier 2 participants 2 messages Oct 14

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

PATCH 1/1 MTD: nand: Fix release_mem_region() size

In au1550nd_probe(), request_mem_region() is called with size resource_size(r), and release_mem_region() is called in the error path with the same size. Howeve, in the cleanup function au1550nd_remove() calls release_mem_region() with size 0x1000.

Change release size to match request.

Fixes b67a1a02d463 ("MTD: nand: make au1550nd.c a platform_driver")
---
 drivers/mtd/nand/raw/au1550nd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/au1550nd.c +1 -1
index f1e99197ab84..623a10dbce55 100644
@@ -348,7 +348,7 @@ static void au1550nd_remove(struct platform_device *pdev)
 	WARN_ON(ret);
 	nand_cleanup(chip);
 	iounmap(ctx->base);
-	release_mem_region(r->start, 0x1000);
+	release_mem_region(r->start, resource_size(r));
 	kfree(ctx);
 }
 
Signature · 1 line
2.53.0
maintainer
#1 lore raw

Hi Thomas,

Quoted 10 lines

In au1550nd_probe(), request_mem_region() is called with size resource_size(r), and release_mem_region() is called in the error path with the same size. Howeve, in the cleanup function au1550nd_remove() calls release_mem_region() with size 0x1000.

Change release size to match request.

Fixes b67a1a02d463 ("MTD: nand: make au1550nd.c a platform_driver")

---

This driver is very old. If you care about cleaning it up, I would suggest doing something bigger. For instance platform_get_resource, request_mem_region and ioremap are now a single helper named devm_platform_ioremap_resource(). The kzalloc could also become device managed. This will further reduce the size of the error path and the removal.

The subject prefix btw should be updated to match today's standards (see git log --oneline -- drivers/mtd/nand/raw/).

Do you own the hardware?

Thanks,
Miquèl