mm: memory-failure: fix potential unexpected return value from unpoison_memory()
authorMiaohe Lin <linmiaohe@huawei.com>
Thu, 27 Jul 2023 11:56:41 +0000 (19:56 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 4 Aug 2023 20:03:41 +0000 (13:03 -0700)
commitf29623e4a599c295cc8f518c8e4bb7848581a14d
tree6c3ec94fa281458632d9734743a7590267796a3d
parentf985fc322063c73916a0d5b6b3fcc6db2ba5792c
mm: memory-failure: fix potential unexpected return value from unpoison_memory()

If unpoison_memory() fails to clear page hwpoisoned flag, return value ret
is expected to be -EBUSY.  But when get_hwpoison_page() returns 1 and
fails to clear page hwpoisoned flag due to races, return value will be
unexpected 1 leading to users being confused.  And there's a code smell
that the variable "ret" is used not only to save the return value of
unpoison_memory(), but also the return value from get_hwpoison_page().
Make a further cleanup by using another auto-variable solely to save the
return value of get_hwpoison_page() as suggested by Naoya.

Link: https://lkml.kernel.org/r/20230727115643.639741-3-linmiaohe@huawei.com
Fixes: bf181c582588 ("mm/hwpoison: fix unpoison_memory()")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory-failure.c