Commit c898c67d authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'dma-mapping-5.19-2022-06-26' of git://git.infradead.org/users/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()
parents be129fab 3be45625
...@@ -357,7 +357,7 @@ void dma_direct_free(struct device *dev, size_t size, ...@@ -357,7 +357,7 @@ void dma_direct_free(struct device *dev, size_t size,
} else { } else {
if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CLEAR_UNCACHED)) if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CLEAR_UNCACHED))
arch_dma_clear_uncached(cpu_addr, size); 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; return;
} }
...@@ -392,7 +392,6 @@ void dma_direct_free_pages(struct device *dev, size_t size, ...@@ -392,7 +392,6 @@ void dma_direct_free_pages(struct device *dev, size_t size,
struct page *page, dma_addr_t dma_addr, struct page *page, dma_addr_t dma_addr,
enum dma_data_direction dir) enum dma_data_direction dir)
{ {
unsigned int page_order = get_order(size);
void *vaddr = page_address(page); void *vaddr = page_address(page);
/* If cpu_addr is not from an atomic pool, dma_free_from_pool() fails */ /* If cpu_addr is not from an atomic pool, dma_free_from_pool() fails */
...@@ -400,7 +399,7 @@ void dma_direct_free_pages(struct device *dev, size_t size, ...@@ -400,7 +399,7 @@ void dma_direct_free_pages(struct device *dev, size_t size,
dma_free_from_pool(dev, vaddr, size)) dma_free_from_pool(dev, vaddr, size))
return; return;
if (dma_set_encrypted(dev, vaddr, 1 << page_order)) if (dma_set_encrypted(dev, vaddr, size))
return; return;
__dma_direct_free_pages(dev, page, size); __dma_direct_free_pages(dev, page, size);
} }
......
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