When CONFIG_DEBUG_VM is not set, VM_WARN_ON is a NOP. Putting any statement with side effect inside it is incorrect. Move put_page_testzero() out and check its return value in VM_WARN_ON. Add __maybe_unused to the return value for when CONFIG_DEBUG_VM is not set. Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()") Reported-by: Ron Economos Closes: https://lore.kernel.org/all/1b17c38f-30d3-4bb4-a7e1-e74b19ada885@w6rz.net/ Signed-off-by: Zi Yan --- Alternatively, we can use WARN_ON instead. Let me know. mm/cma.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index 94b5da468a7d..a9fe6e9a9215 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -1020,8 +1020,11 @@ bool cma_release(struct cma *cma, const struct page *pages, return false; pfn = page_to_pfn(pages); - for (i = 0; i < count; i++, pfn++) - VM_WARN_ON(!put_page_testzero(pfn_to_page(pfn))); + for (i = 0; i < count; i++, pfn++) { + int __maybe_unused ret = put_page_testzero(pfn_to_page(pfn)); + + VM_WARN_ON(!ret); + } __cma_release_frozen(cma, cmr, pages, count); -- 2.51.0