Skip to content

Commit 1130b25

Browse files
Alex Elderkuba-moo
authored andcommitted
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: 9dd441e ("soc: qcom: ipa: GSI transactions") Reported-by: Stephen Boyd <[email protected]> Tested-by: Sujit Kautkar <[email protected]> Signed-off-by: Alex Elder <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4eef8b1 commit 1130b25

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/net/ipa/gsi_trans.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ int gsi_trans_pool_init_dma(struct device *dev, struct gsi_trans_pool *pool,
156156
/* The allocator will give us a power-of-2 number of pages. But we
157157
* can't guarantee that, so request it. That way we won't waste any
158158
* memory that would be available beyond the required space.
159+
*
160+
* Note that gsi_trans_pool_exit_dma() assumes the total allocated
161+
* size is exactly (count * size).
159162
*/
160163
total_size = get_order(total_size) << PAGE_SHIFT;
161164

@@ -175,7 +178,9 @@ int gsi_trans_pool_init_dma(struct device *dev, struct gsi_trans_pool *pool,
175178

176179
void gsi_trans_pool_exit_dma(struct device *dev, struct gsi_trans_pool *pool)
177180
{
178-
dma_free_coherent(dev, pool->size, pool->base, pool->addr);
181+
size_t total_size = pool->count * pool->size;
182+
183+
dma_free_coherent(dev, total_size, pool->base, pool->addr);
179184
memset(pool, 0, sizeof(*pool));
180185
}
181186

0 commit comments

Comments
 (0)