diff --git a/mm/gup.c b/mm/gup.c
index bb4ad57d20e341e4581bec066aecb009aed1c168..43b7d875de3716fb20353fb732ddcc531b5f2b54 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1796,7 +1796,8 @@ static inline pte_t gup_get_pte(pte_t *ptep)
 }
 #endif /* CONFIG_GUP_GET_PTE_LOW_HIGH */
 
-static void undo_dev_pagemap(int *nr, int nr_start, struct page **pages)
+static void __maybe_unused undo_dev_pagemap(int *nr, int nr_start,
+					    struct page **pages)
 {
 	while ((*nr) - nr_start) {
 		struct page *page = pages[--(*nr)];