History

mm/gup: fix a misnamed "write" argument, and a related bug

In several routines, the "flags" argument is incorrectly named "write". Change it to "flags". Also, in one place, the misnaming led to an actual bug: "flags & FOLL_WRITE" is required, rather than just "flags". (That problem was flagged by krobot, in v1 of this patch.) Also, change the flags argument from int, to unsigned int. You can see that this was a simple oversight, because the calling code passes "flags" to the fifth argument: gup_pgd_range(): ... if (!gup_huge_pd(__hugepd(pgd_val(pgd)), addr, PGDIR_SHIFT, next, flags, pages, nr)) ...which, until this patch, the callees referred to as "write". Also, change two lines to avoid checkpatch line length complaints, and another line to fix another oversight that checkpatch called out: missing "int" on pdshift.

John Hubbard committed 7 years ago

Commit 0cd22af1 parent 6f24c8d1 file · +8 −6Browse files

Unified · Split

mm/gup.c+8−6
@@ -1973,7 +1973,8 @@ static unsigned long hugepte_addr_end(unsigned long addr, unsigned long end, · 1972 unmodified lines
19731973 }
19741974
19751975 static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
1976− unsigned long end, int write, struct page **pages, int *nr)
1976+ unsigned long end, unsigned int flags,
1977+ struct page **pages, int *nr)
19771978 {
19781979 unsigned long pte_end;
19791980 struct page *head, *page;
@@ -1986,7 +1987,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, · 6 unmodified lines
19861987
19871988 pte = READ_ONCE(*ptep);
19881989
1989− if (!pte_access_permitted(pte, write))
1990+ if (!pte_access_permitted(pte, flags & FOLL_WRITE))
19901991 return 0;
19911992
19921993 /* hugepages are never "special" */
@@ -2023,7 +2024,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, · 30 unmodified lines
20232024 }
20242025
20252026 static int gup_huge_pd(hugepd_t hugepd, unsigned long addr,
2026− unsigned int pdshift, unsigned long end, int write,
2027+ unsigned int pdshift, unsigned long end, unsigned int flags,
20272028 struct page **pages, int *nr)
20282029 {
20292030 pte_t *ptep;
@@ -2033,7 +2034,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, · 3 unmodified lines
20332034 ptep = hugepte_offset(hugepd, addr, pdshift);
20342035 do {
20352036 next = hugepte_addr_end(addr, end, sz);
2036− if (!gup_hugepte(ptep, sz, addr, end, write, pages, nr))
2037+ if (!gup_hugepte(ptep, sz, addr, end, flags, pages, nr))
20372038 return 0;
20382039 } while (ptep++, addr = next, addr != end);
20392040
@@ -2041,7 +2042,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, · 1 unmodified line
20412042 }
20422043 #else
20432044 static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr,
2044− unsigned pdshift, unsigned long end, int write,
2045+ unsigned int pdshift, unsigned long end, unsigned int flags,
20452046 struct page **pages, int *nr)
20462047 {
20472048 return 0;
@@ -2049,7 +2050,8 @@ static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr, · 1 unmodified line
20492050 #endif /* CONFIG_ARCH_HAS_HUGEPD */
20502051
20512052 static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
2052− unsigned long end, unsigned int flags, struct page **pages, int *nr)
2053+ unsigned long end, unsigned int flags,
2054+ struct page **pages, int *nr)
20532055 {
20542056 struct page *head, *page;
20552057 int refs;