mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 05:39:54 -04:00
Merge "iommu: iommu-debug: check valid pfn before performing ATOS ops"
This commit is contained in:
commit
7a21e4007b
1 changed files with 9 additions and 0 deletions
|
|
@ -1569,6 +1569,8 @@ static ssize_t iommu_debug_atos_write(struct file *file,
|
|||
{
|
||||
struct iommu_debug_device *ddev = file->private_data;
|
||||
dma_addr_t iova;
|
||||
phys_addr_t phys;
|
||||
unsigned long pfn;
|
||||
|
||||
if (kstrtox_from_user(ubuf, count, 0, &iova)) {
|
||||
pr_err_ratelimited("Invalid format for iova\n");
|
||||
|
|
@ -1576,7 +1578,14 @@ static ssize_t iommu_debug_atos_write(struct file *file,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
phys = iommu_iova_to_phys(ddev->domain, ddev->iova);
|
||||
pfn = __phys_to_pfn(phys);
|
||||
if (!pfn_valid(pfn)) {
|
||||
dev_err(ddev->dev, "Invalid ATOS operation page %pa\n", &phys);
|
||||
return -EINVAL;
|
||||
}
|
||||
ddev->iova = iova;
|
||||
|
||||
pr_err_ratelimited("Saved iova=%pa for future ATOS commands\n", &iova);
|
||||
return count;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue