mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 15:11:48 -04:00
Merge "iommu-debug: allocate test_virt_addr when reading it"
This commit is contained in:
commit
15af7d21bc
1 changed files with 20 additions and 9 deletions
|
|
@ -1472,9 +1472,13 @@ static ssize_t iommu_debug_test_virt_addr_read(struct file *file,
|
|||
|
||||
memset(buf, 0, buf_len);
|
||||
|
||||
if (!test_virt_addr)
|
||||
if (IS_ERR_OR_NULL(test_virt_addr))
|
||||
test_virt_addr = kzalloc(SZ_1M, GFP_KERNEL);
|
||||
|
||||
if (!test_virt_addr) {
|
||||
test_virt_addr = ERR_PTR(-ENOMEM);
|
||||
strlcpy(buf, "FAIL\n", buf_len);
|
||||
else
|
||||
} else
|
||||
snprintf(buf, buf_len, "0x%pK\n", test_virt_addr);
|
||||
|
||||
return simple_read_from_buffer(ubuf, count, offset, buf, strlen(buf));
|
||||
|
|
@ -1804,6 +1808,12 @@ static ssize_t iommu_debug_dma_map_write(struct file *file,
|
|||
if (kstrtouint(comma2 + 1, 0, &attr))
|
||||
goto invalid_format;
|
||||
|
||||
if (IS_ERR(test_virt_addr))
|
||||
goto allocation_failure;
|
||||
|
||||
if (!test_virt_addr)
|
||||
goto missing_allocation;
|
||||
|
||||
if (v_addr < test_virt_addr || v_addr + size > test_virt_addr + SZ_1M)
|
||||
goto invalid_addr;
|
||||
|
||||
|
|
@ -1851,6 +1861,14 @@ invalid_format:
|
|||
invalid_addr:
|
||||
pr_err_ratelimited("Invalid addr given! Address should be within 1MB size from start addr returned by doing 'cat test_virt_addr'.\n");
|
||||
return retval;
|
||||
|
||||
allocation_failure:
|
||||
pr_err_ratelimited("Allocation of test_virt_addr failed.\n");
|
||||
return -ENOMEM;
|
||||
|
||||
missing_allocation:
|
||||
pr_err_ratelimited("Please attempt to do 'cat test_virt_addr'.\n");
|
||||
return retval;
|
||||
}
|
||||
|
||||
static ssize_t iommu_debug_dma_map_read(struct file *file, char __user *ubuf,
|
||||
|
|
@ -2358,13 +2376,6 @@ static int iommu_debug_init_tests(void)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
test_virt_addr = kzalloc(SZ_1M, GFP_KERNEL);
|
||||
|
||||
if (!test_virt_addr) {
|
||||
debugfs_remove_recursive(debugfs_tests_dir);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue