If the __swap_duplicate returns a negative value except of the -ENOMEM, but the err is zero at this time, the return value of swap_duplicate is wrong in this situation. The caller, such as try_to_unmap_one(), will do the wrong operations too in this situation. This patch fix it. Signed-off-by: Huang Shijie <shijie8@xxxxxxxxx> --- mm/swapfile.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 6c0585b..191d8fa 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2161,7 +2161,7 @@ int swap_duplicate(swp_entry_t entry) { int err = 0; - while (!err && __swap_duplicate(entry, 1) == -ENOMEM) + while (!err && (err = __swap_duplicate(entry, 1)) == -ENOMEM) err = add_swap_count_continuation(entry, GFP_ATOMIC); return err; } -- 1.6.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxxx For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>