Feature #5357
open203: All allocated IO-memory should be freed
0%
Description
- freeing all allocated regions to avoid a memory leak;
- freeing an allocated memory region only once;
- freeing only allocated memory region;
- allocate a particular memory region only once.
Updated by Anton Vasilyev over 7 years ago
Require to separate 2 different resource groups:
1 for io resource:
#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name), 0)
#define request_muxed_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name), IORESOURCE_MUXED)
#define release_region(start,n) __release_region(&ioport_resource, (start), (n))
2 for memory region:
#define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name), 0)
#define request_mem_region_exclusive(start,n,name) \
__request_region(&iomem_resource, (start), (n), (name), IORESOURCE_EXCLUSIVE)
#define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n))
Example with wrong alloc/release pair:
http://lxr.free-electrons.com/source/drivers/i2c/busses/i2c-simtec.c?v=4.9#L90
http://lxr.free-electrons.com/source/drivers/i2c/busses/i2c-simtec.c?v=4.9#L130