Re: [REF PATCH] mm/swap: fix swapon failure

From: linmiaohe
Date: Mon Nov 09 2020 - 07:07:59 EST


Hi:
Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx> wrote:
> One of my VM guest has a swapon issue:
> root #swapon -v -f /swap1
> swapon /swap1
> swapon: /swap1: found swap signature: version 1, page-size 4, same byte order
> swapon: /swap1: pagesize=4096, swapsize=1607467008, devsize=1607467008
> swapon: /swap1: swapon failed: Invalid argument
>
> and bisection report commit 822bca52ee7e "mm/swapfile.c: fix potential memory leak in sys_swapon" cause the trouble.
>
> Go through the context I found the exit_swap_address_space(p->type) shouldn't be used in good result path. So just move it to error path.
>

Many thanks for your patch. But I'am somehow confused as we only do the label free_swap_address_space stuff in error path. And the good result
path can't reach here as it just goto out before free_swap_address_space label. Could you please explain it for me more detailed?

Thanks again.

> Fixes: 822bca52ee7e ("mm/swapfile.c: fix potential memory leak in
> sys_swapon")
> Signed-off-by: Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>