Skip to content

Commit 220c491

Browse files
XianLiang Huanggregkh
authored andcommitted
iommu/riscv: prevent NULL deref in iova_to_phys
commit 99d4d1a upstream. The riscv_iommu_pte_fetch() function returns either NULL for unmapped/never-mapped iova, or a valid leaf pte pointer that requires no further validation. riscv_iommu_iova_to_phys() failed to handle NULL returns. Prevent null pointer dereference in riscv_iommu_iova_to_phys(), and remove the pte validation. Fixes: 488ffbf ("iommu/riscv: Paging domain support") Cc: Tomasz Jeznach <tjeznach@rivosinc.com> Signed-off-by: XianLiang Huang <huangxianliang@lanxincomputing.com> Link: https://lore.kernel.org/r/20250820072248.312-1-huangxianliang@lanxincomputing.com Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7ec68c5 commit 220c491

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iommu/riscv/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain,
12831283
unsigned long *ptr;
12841284

12851285
ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
1286-
if (_io_pte_none(*ptr) || !_io_pte_present(*ptr))
1286+
if (!ptr)
12871287
return 0;
12881288

12891289
return pfn_to_phys(__page_val_to_pfn(*ptr)) | (iova & (pte_size - 1));

0 commit comments

Comments
 (0)