Skip to content

Commit 6b0c54e

Browse files
Yunsheng Linjoergroedel
authored andcommitted
iommu/dma: Fix for dereferencing before null checking
The cookie is dereferenced before null checking in the function iommu_dma_init_domain. This patch moves the dereferencing after the null checking. Fixes: fdbe574 ("iommu/dma: Allow MSI-only cookies") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 4dbd258 commit 6b0c54e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/iommu/dma-iommu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,15 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base,
303303
u64 size, struct device *dev)
304304
{
305305
struct iommu_dma_cookie *cookie = domain->iova_cookie;
306-
struct iova_domain *iovad = &cookie->iovad;
307306
unsigned long order, base_pfn;
307+
struct iova_domain *iovad;
308308
int attr;
309309

310310
if (!cookie || cookie->type != IOMMU_DMA_IOVA_COOKIE)
311311
return -EINVAL;
312312

313+
iovad = &cookie->iovad;
314+
313315
/* Use the smallest supported page size for IOVA granularity */
314316
order = __ffs(domain->pgsize_bitmap);
315317
base_pfn = max_t(unsigned long, 1, base >> order);

0 commit comments

Comments
 (0)