Skip to content

Commit

Permalink
Merge tag 'dma-mapping-5.19-2022-06-26' of git://git.infradead.org/us…
Browse files Browse the repository at this point in the history
…ers/hch/dma-mapping

Pull dma-mapping fix from Christoph Hellwig:

 - pass the correct size to dma_set_encrypted() when freeing memory
   (Dexuan Cui)

* tag 'dma-mapping-5.19-2022-06-26' of git://git.infradead.org/users/hch/dma-mapping:
  dma-direct: use the correct size for dma_set_encrypted()
  • Loading branch information
Linus Torvalds committed Jun 26, 2022
2 parents be129fa + 3be4562 commit c898c67
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions kernel/dma/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void dma_direct_free(struct device *dev, size_t size,
} else {
if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CLEAR_UNCACHED))
arch_dma_clear_uncached(cpu_addr, size);
if (dma_set_encrypted(dev, cpu_addr, 1 << page_order))
if (dma_set_encrypted(dev, cpu_addr, size))
return;
}

Expand Down Expand Up @@ -392,15 +392,14 @@ void dma_direct_free_pages(struct device *dev, size_t size,
struct page *page, dma_addr_t dma_addr,
enum dma_data_direction dir)
{
unsigned int page_order = get_order(size);
void *vaddr = page_address(page);

/* If cpu_addr is not from an atomic pool, dma_free_from_pool() fails */
if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) &&
dma_free_from_pool(dev, vaddr, size))
return;

if (dma_set_encrypted(dev, vaddr, 1 << page_order))
if (dma_set_encrypted(dev, vaddr, size))
return;
__dma_direct_free_pages(dev, page, size);
}
Expand Down

0 comments on commit c898c67

Please sign in to comment.