Skip to contentSkip to conversation

mm/swap: fix swapon failure

PATCH linmiaohe 1 participant 1 message Nov 9, 2020 Memory management

lore
Share & tools
lore

linmiaohe

author
#0 lore raw

Hi:

Quoted 11 lines · Alex Shi

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.

Quoted 4 lines
Fixes 822bca52ee7e ("mm/swapfile.c: fix potential memory leak in

sys_swapon")

Cc Andrew Morton <[email protected]>