Project

General

Profile

Actions

Feature #5357

open

203: All allocated IO-memory should be freed

Added by Pavel Andrianov about 10 years ago. Updated over 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Start date:
10/20/2014
Due date:
% Done:

0%

Estimated time:
Published in build:

Description

The region of memory is allocated by macrofunction request_mem_region(start, n, name), which takes a start of memory region and its size. The allocated memory region is freed by macrofunction release_mem_region(start, n). The rules of correct usage are:
  • 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.

Sample bugfixes
665c715
984814d

Actions #1

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

Actions

Also available in: Atom PDF