diff --git a/mm/gup.c b/mm/gup.c index b128350772de..5168665da584 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -88,6 +88,14 @@ static __maybe_unused struct page *try_grab_compound_head(struct page *page, else if (flags & FOLL_PIN) { int orig_refs = refs; + /* + * Can't do FOLL_LONGTERM + FOLL_PIN with CMA in the gup fast + * path, so fail and let the caller fall back to the slow path. + */ + if (unlikely(flags & FOLL_LONGTERM) && + is_migrate_cma_page(page)) + return NULL; + /* * When pinning a compound page of order > 1 (which is what * hpage_pincount_available() checks for), use an exact count to