summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGowtham Tammana2016-12-20 13:34:52 -0600
committerGowtham Tammana2016-12-23 07:48:52 -0600
commit7c0f4dc755dc2ecb95195ed42ef24fea16ef2667 (patch)
tree9dfd39d20bdeb9af86f26fe8f3a83ca979978324
parent4b4e25f792a343d7233afbec816c7ae56deb645c (diff)
downloadti-gc320-driver-7c0f4dc755dc2ecb95195ed42ef24fea16ef2667.tar.gz
ti-gc320-driver-7c0f4dc755dc2ecb95195ed42ef24fea16ef2667.tar.xz
ti-gc320-driver-7c0f4dc755dc2ecb95195ed42ef24fea16ef2667.zip
Remove spurious page count increment
get_page() is being called twice during page table walk of vma region. Removing the additional call and also adding error checks while traversing page table entries. Signed-off-by: Gowtham Tammana <g-tammana@ti.com>
-rwxr-xr-xsrc/hal/os/linux/kernel/gc_hal_kernel_os.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/hal/os/linux/kernel/gc_hal_kernel_os.c b/src/hal/os/linux/kernel/gc_hal_kernel_os.c
index 546a188..34b50e3 100755
--- a/src/hal/os/linux/kernel/gc_hal_kernel_os.c
+++ b/src/hal/os/linux/kernel/gc_hal_kernel_os.c
@@ -4813,29 +4813,45 @@ OnError:
4813 4813
4814 for (i = 0; i < pageCount; i++) 4814 for (i = 0; i < pageCount; i++)
4815 { 4815 {
4816 pgd_t * pgd = pgd_offset(current->mm, logical); 4816 pgd_t *pgd;
4817 pud_t * pud = pud_offset(pgd, logical); 4817 pud_t *pud;
4818 pmd_t *pmd;
4818 4819
4819 if (pud) 4820 pgd = pgd_offset(vma->vm_mm, logical);
4821 if (pgd_none(*pgd) || pgd_bad(*pgd))
4820 { 4822 {
4821 pmd_t * pmd = pmd_offset(pud, logical); 4823 gckOS_DebugTrace(gcvLEVEL_ERROR,
4822 pte = pte_offset_map_lock(current->mm, pmd, logical, &ptl); 4824 "Invalid pgd entry at page %d\n", i);
4823 if (!pte) 4825 gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES);
4824 { 4826 }
4825 gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES); 4827
4826 } 4828 pud = pud_offset(pgd, logical);
4829 if (pud_none(*pud) || pud_bad(*pud))
4830 {
4831 gckOS_DebugTrace(gcvLEVEL_ERROR,
4832 "Invalid pud entry at page %d\n", i);
4833 gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES);
4834 }
4835
4836 pmd = pmd_offset(pud, logical);
4837 if (pmd_none(*pmd) || pmd_bad(*pmd))
4838 {
4839 gckOS_DebugTrace(gcvLEVEL_ERROR,
4840 "Invalid pmd entry at page %d\n", i);
4841 gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES);
4827 } 4842 }
4828 else 4843
4844 pte = (pte_t *)pte_offset_map_lock(vma->vm_mm, pmd, logical, &ptl);
4845 if (pte_none(*pte) || !pte_present(*pte) || !pte_write(*pte))
4829 { 4846 {
4847 pte_unmap_unlock(pte, ptl);
4848 gckOS_DebugTrace(gcvLEVEL_ERROR,
4849 "Invalid pte entry at page %d\n", i);
4850
4830 gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES); 4851 gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES);
4831 } 4852 }
4832 4853
4833 pages[i] = pte_page(*pte); 4854 pages[i] = pte_page(*pte);
4834 /*
4835 * inc refcount for the page, refcount is decremented by
4836 * the kernel when the vma is unmapped.
4837 */
4838 get_page(pages[i]);
4839 pte_unmap_unlock(pte, ptl); 4855 pte_unmap_unlock(pte, ptl);
4840 4856
4841 /* 4857 /*