arm: dma-mapping: fix memory leak about dma iommu mapping
When doing multiple attach/detach tests in iommu-debug,
arch_setup_dma_ops/arch_teardown_dma_ops will be executed multiple
times, the created mapping and its bitmaps by arch_setup_dma_ops
are not freed by arch_teardown_dma_ops because refcount of
mapping->kref is 1 not 0, so memory leak happens, in iommu-debug cases,
each bitmap is requested to allocate PAGE_SIZE with kmalloc, the memory
of slub named kmalloc-4096 is observed to become bigger and bigger, then
will result in OOM easily because of limited lowmem on 32 bit system.
The reason is arch_setup_dma_ops has one needless kref_get operation:
arch_setup_dma_ops -> kref_init(&mapping->kref)
&& kref_get(&mapping->kref).
arch_teardown_dma_ops -> kref_put(&mapping->kref).
Change-Id: I9823ff0ccd5b752774f843592d788e37199166c4
Signed-off-by:
Qingqing Zhou <qqzhou@codeaurora.org>
Loading
Please register or sign in to comment