Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit dd2bb392 authored by Qingqing Zhou's avatar Qingqing Zhou
Browse files

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: default avatarQingqing Zhou <qqzhou@codeaurora.org>
parent 74879d9a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment