[PATCH 3/6] mm, hwpoison: fix extra put_page() in soft_offline_page()

Miaohe Lin posted 6 patches 3 years, 7 months ago
There is a newer version of this series
[PATCH 3/6] mm, hwpoison: fix extra put_page() in soft_offline_page()
Posted by Miaohe Lin 3 years, 7 months ago
When hwpoison_filter() refuses to soft offline a page, the page refcnt
incremented previously by MF_COUNT_INCREASED would have been consumed
via get_hwpoison_page() if ret <= 0. So the put_ref_page() here will
put the extra one. Remove it to fix the issue.

Fixes: 9113eaf331bf ("mm/memory-failure.c: add hwpoison_filter for soft offline")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/memory-failure.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 0c5ad7505b99..7023c3d81273 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2591,8 +2591,6 @@ int soft_offline_page(unsigned long pfn, int flags)
 	if (hwpoison_filter(page)) {
 		if (ret > 0)
 			put_page(page);
-		else
-			put_ref_page(ref_page);
 
 		mutex_unlock(&mf_mutex);
 		return -EOPNOTSUPP;
-- 
2.23.0
Re: [PATCH 3/6] mm, hwpoison: fix extra put_page() in soft_offline_page()
Posted by HORIGUCHI NAOYA(堀口 直也) 3 years, 7 months ago
On Thu, Aug 18, 2022 at 09:00:13PM +0800, Miaohe Lin wrote:
> When hwpoison_filter() refuses to soft offline a page, the page refcnt
> incremented previously by MF_COUNT_INCREASED would have been consumed
> via get_hwpoison_page() if ret <= 0. So the put_ref_page() here will
> put the extra one. Remove it to fix the issue.
> 
> Fixes: 9113eaf331bf ("mm/memory-failure.c: add hwpoison_filter for soft offline")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>

> ---
>  mm/memory-failure.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 0c5ad7505b99..7023c3d81273 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2591,8 +2591,6 @@ int soft_offline_page(unsigned long pfn, int flags)
>  	if (hwpoison_filter(page)) {
>  		if (ret > 0)
>  			put_page(page);
> -		else
> -			put_ref_page(ref_page);
>  
>  		mutex_unlock(&mf_mutex);
>  		return -EOPNOTSUPP;
> -- 
> 2.23.0