diff options
author | David S. Miller <davem@davemloft.net> | 2015-11-04 14:30:57 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-11-04 14:30:57 -0500 |
commit | d618382ba5f1a4905db63f4980bf7b0a5826de9d (patch) | |
tree | 5bc612d222a70276b0e4d9df476b2548c1286d9e /lib | |
parent | 73958c651fbf70d8d8bf2a60b871af5f7a2e3199 (diff) |
iommu-common: Fix error code used in iommu_tbl_range_{alloc,free}().
The value returned from iommu_tbl_range_alloc() (and the one passed
in as a fourth argument to iommu_tbl_range_free) is not a DMA address,
it is rather an index into the IOMMU page table.
Therefore using DMA_ERROR_CODE is not appropriate.
Use a more type matching error code define, IOMMU_ERROR_CODE, and
update all users of this interface.
Reported-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/iommu-common.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/iommu-common.c b/lib/iommu-common.c index ff19f66d3f7f..0f2c887be770 100644 --- a/lib/iommu-common.c +++ b/lib/iommu-common.c | |||
@@ -11,10 +11,6 @@ | |||
11 | #include <linux/dma-mapping.h> | 11 | #include <linux/dma-mapping.h> |
12 | #include <linux/hash.h> | 12 | #include <linux/hash.h> |
13 | 13 | ||
14 | #ifndef DMA_ERROR_CODE | ||
15 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) | ||
16 | #endif | ||
17 | |||
18 | static unsigned long iommu_large_alloc = 15; | 14 | static unsigned long iommu_large_alloc = 15; |
19 | 15 | ||
20 | static DEFINE_PER_CPU(unsigned int, iommu_hash_common); | 16 | static DEFINE_PER_CPU(unsigned int, iommu_hash_common); |
@@ -124,7 +120,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev, | |||
124 | /* Sanity check */ | 120 | /* Sanity check */ |
125 | if (unlikely(npages == 0)) { | 121 | if (unlikely(npages == 0)) { |
126 | WARN_ON_ONCE(1); | 122 | WARN_ON_ONCE(1); |
127 | return DMA_ERROR_CODE; | 123 | return IOMMU_ERROR_CODE; |
128 | } | 124 | } |
129 | 125 | ||
130 | if (largealloc) { | 126 | if (largealloc) { |
@@ -207,7 +203,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev, | |||
207 | goto again; | 203 | goto again; |
208 | } else { | 204 | } else { |
209 | /* give up */ | 205 | /* give up */ |
210 | n = DMA_ERROR_CODE; | 206 | n = IOMMU_ERROR_CODE; |
211 | goto bail; | 207 | goto bail; |
212 | } | 208 | } |
213 | } | 209 | } |
@@ -259,7 +255,7 @@ void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr, | |||
259 | unsigned long flags; | 255 | unsigned long flags; |
260 | unsigned long shift = iommu->table_shift; | 256 | unsigned long shift = iommu->table_shift; |
261 | 257 | ||
262 | if (entry == DMA_ERROR_CODE) /* use default addr->entry mapping */ | 258 | if (entry == IOMMU_ERROR_CODE) /* use default addr->entry mapping */ |
263 | entry = (dma_addr - iommu->table_map_base) >> shift; | 259 | entry = (dma_addr - iommu->table_map_base) >> shift; |
264 | pool = get_pool(iommu, entry); | 260 | pool = get_pool(iommu, entry); |
265 | 261 | ||