Commit 1130b252 authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: pass the correct size when freeing DMA memory

When the coherent memory is freed in gsi_trans_pool_exit_dma(), we
are mistakenly passing the size of a single element in the pool
rather than the actual allocated size.  Fix this bug.

Fixes: 9dd441e4 ("soc: qcom: ipa: GSI transactions")
Reported-by: default avatarStephen Boyd <swboyd@chromium.org>
Tested-by: default avatarSujit Kautkar <sujitka@chromium.org>
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20201203215106.17450-1-elder@linaro.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4eef8b1f
...@@ -156,6 +156,9 @@ int gsi_trans_pool_init_dma(struct device *dev, struct gsi_trans_pool *pool, ...@@ -156,6 +156,9 @@ int gsi_trans_pool_init_dma(struct device *dev, struct gsi_trans_pool *pool,
/* The allocator will give us a power-of-2 number of pages. But we /* The allocator will give us a power-of-2 number of pages. But we
* can't guarantee that, so request it. That way we won't waste any * can't guarantee that, so request it. That way we won't waste any
* memory that would be available beyond the required space. * memory that would be available beyond the required space.
*
* Note that gsi_trans_pool_exit_dma() assumes the total allocated
* size is exactly (count * size).
*/ */
total_size = get_order(total_size) << PAGE_SHIFT; total_size = get_order(total_size) << PAGE_SHIFT;
...@@ -175,7 +178,9 @@ int gsi_trans_pool_init_dma(struct device *dev, struct gsi_trans_pool *pool, ...@@ -175,7 +178,9 @@ int gsi_trans_pool_init_dma(struct device *dev, struct gsi_trans_pool *pool,
void gsi_trans_pool_exit_dma(struct device *dev, struct gsi_trans_pool *pool) void gsi_trans_pool_exit_dma(struct device *dev, struct gsi_trans_pool *pool)
{ {
dma_free_coherent(dev, pool->size, pool->base, pool->addr); size_t total_size = pool->count * pool->size;
dma_free_coherent(dev, total_size, pool->base, pool->addr);
memset(pool, 0, sizeof(*pool)); memset(pool, 0, sizeof(*pool));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment