Skip to content

Commit 8ecc369

Browse files
keithbuschakpm00
authored andcommitted
dmapool: don't memset on free twice
If debug is enabled, dmapool will poison the range, so no need to clear it to 0 immediately before writing over it. Link: https://lkml.kernel.org/r/20230126215125.4069751-11-kbusch@meta.com Fixes: 2d55c16 ("dmapool: create/destroy cleanup") Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Matthew Wilcox <willy@infradead.org> Cc: Tony Battersby <tonyb@cybernetics.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent cc66995 commit 8ecc369

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/dmapool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ static void pool_check_block(struct dma_pool *pool, void *retval,
160160
static bool pool_page_err(struct dma_pool *pool, struct dma_page *page,
161161
void *vaddr, dma_addr_t dma)
162162
{
163+
if (want_init_on_free())
164+
memset(vaddr, 0, pool->size);
163165
return false;
164166
}
165167

@@ -441,8 +443,6 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
441443
return;
442444
}
443445

444-
if (want_init_on_free())
445-
memset(vaddr, 0, pool->size);
446446
if (pool_page_err(pool, page, vaddr, dma)) {
447447
spin_unlock_irqrestore(&pool->lock, flags);
448448
return;

0 commit comments

Comments
 (0)