History

mm/page_alloc: restrict and formalize compound_page_dtors[]

Restrict elements in compound_page_dtors[] array per NR_COMPOUND_DTORS and explicitly position them according to enum compound_dtor_id. This improves protection against possible misalignment between compound_page_dtors[] and enum compound_dtor_id later on.

Anshuman Khandual committed 6 years ago

Commit ae70edd1 parent aa092592 files · +6 −6Browse files

Unified · Split

2 files
  1. include/linux/mm.h +1 −1
  2. mm/page_alloc.c +5 −5
include/linux/mm.h+1−1
@@ -867,7 +867,7 @@ enum compound_dtor_id { · 866 unmodified lines
867#endif867#endif
868 NR_COMPOUND_DTORS,868 NR_COMPOUND_DTORS,
869};869};
870extern compound_page_dtor * const compound_page_dtors[];870extern compound_page_dtor * const compound_page_dtors[NR_COMPOUND_DTORS];
871 871
872static inline void set_compound_page_dtor(struct page *page,872static inline void set_compound_page_dtor(struct page *page,
873 enum compound_dtor_id compound_dtor)873 enum compound_dtor_id compound_dtor)
mm/page_alloc.c+5−5
@@ -302,14 +302,14 @@ const char * const migratetype_names[MIGRATE_TYPES] = { · 301 unmodified lines
302#endif302#endif
303};303};
304 304
305compound_page_dtor * const compound_page_dtors[] = {305compound_page_dtor * const compound_page_dtors[NR_COMPOUND_DTORS] = {
306 NULL,306 [NULL_COMPOUND_DTOR] = NULL,
307 free_compound_page,307 [COMPOUND_PAGE_DTOR] = free_compound_page,
308#ifdef CONFIG_HUGETLB_PAGE308#ifdef CONFIG_HUGETLB_PAGE
309 free_huge_page,309 [HUGETLB_PAGE_DTOR] = free_huge_page,
310#endif310#endif
311#ifdef CONFIG_TRANSPARENT_HUGEPAGE311#ifdef CONFIG_TRANSPARENT_HUGEPAGE
312 free_transhuge_page,312 [TRANSHUGE_PAGE_DTOR] = free_transhuge_page,
313#endif313#endif
314};314};
315 315