Commit 7d58cb34 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Wenchao Hao
Browse files

UPSTREAM: mm: fix list corruption in put_pages_list

My recent change to put_pages_list() dereferences folio->lru.next after
returning the folio to the page allocator.  Usually this is now on the pcp
list with other free folios, so we try to free an already-free folio.
This only happens with lists that have more than 15 entries, so it wasn't
immediately discovered.  Revert to using list_for_each_safe() so we
dereference lru.next before disposing of the folio.

Link: https://lkml.kernel.org/r/20240306212749.1823380-1-willy@infradead.org


Fixes: 24835f89 ("mm: use free_unref_folios() in put_pages_list()")
Change-Id: I9f9e2d354da7b51c5e47d3c1dff3df44460b6df8
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: default avatar"Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Closes: https://lore.kernel.org/intel-gfx/SJ1PR11MB61292145F3B79DA58ADDDA63B9232@SJ1PR11MB6129.namprd11.prod.outlook.com/


Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
(cherry picked from commit b555895c)
Bug: 419599659
Bug: 427173548
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
Signed-off-by: default avatarWenchao Hao <haowenchao@xiaomi.com>
parent 310ccf60
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment