]> git.baikalelectronics.ru Git - kernel.git/commit
mm/huge_memory: Fix xarray node memory leak
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 8 Jun 2022 19:18:34 +0000 (15:18 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 9 Jun 2022 20:24:25 +0000 (16:24 -0400)
commit92958cb8b4cef497dbc88286adec5d19ca78fa40
tree5b201858763ce5ab35ef56217b735902c53804f2
parenta084280e8714ee8a83bf1825eb19b6b7ea417407
mm/huge_memory: Fix xarray node memory leak

If xas_split_alloc() fails to allocate the necessary nodes to complete the
xarray entry split, it sets the xa_state to -ENOMEM, which xas_nomem()
then interprets as "Please allocate more memory", not as "Please free
any unnecessary memory" (which was the intended outcome).  It's confusing
to use xas_nomem() to free memory in this context, so call xas_destroy()
instead.

Reported-by: syzbot+9e27a75a8c24f3fe75c1@syzkaller.appspotmail.com
Fixes: b630484fb760 ("mm: Use multi-index entries in the page cache")
Cc: stable@vger.kernel.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/xarray.h
lib/xarray.c
mm/huge_memory.c