mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
dma-mapping: fix off-by-one error in dma_capable()
dma_mask is, when interpreted as address, the last valid byte, and hence comparison msut also be done using the last valid of the buffer in question. Also fix the open-coded instances in lib/swiotlb.c. Signed-off-by: Jan Beulich <[email protected]> Cc: FUJITA Tomonori <[email protected]> Cc: Becky Bruce <[email protected]> Cc: "Luck, Tony" <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
bbead2104e
commit
ac2b3e67dd
4 changed files with 5 additions and 5 deletions
|
|
@ -549,7 +549,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
|
|||
dma_mask = hwdev->coherent_dma_mask;
|
||||
|
||||
ret = (void *)__get_free_pages(flags, order);
|
||||
if (ret && swiotlb_virt_to_bus(hwdev, ret) + size > dma_mask) {
|
||||
if (ret && swiotlb_virt_to_bus(hwdev, ret) + size - 1 > dma_mask) {
|
||||
/*
|
||||
* The allocated memory isn't reachable by the device.
|
||||
*/
|
||||
|
|
@ -571,7 +571,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
|
|||
dev_addr = swiotlb_virt_to_bus(hwdev, ret);
|
||||
|
||||
/* Confirm address can be DMA'd by device */
|
||||
if (dev_addr + size > dma_mask) {
|
||||
if (dev_addr + size - 1 > dma_mask) {
|
||||
printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n",
|
||||
(unsigned long long)dma_mask,
|
||||
(unsigned long long)dev_addr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue