ksm: swap the two output parameters of chain/chain_prune
authorAndrea Arcangeli <[email protected]>
Thu, 6 Jul 2017 22:37:05 +0000 (15:37 -0700)
committerLinus Torvalds <[email protected]>
Thu, 6 Jul 2017 23:24:31 +0000 (16:24 -0700)
commit8dc5ffcd5a74da39ed2c533d786a3f78671a38b8
treef766ea40745f1b564a8a49a35855c718d97d5985
parent0ba1d0f7c41cdab306a3d30e036bc393c3ebba7e
ksm: swap the two output parameters of chain/chain_prune

Some static checker complains if chain/chain_prune returns a potentially
stale pointer.

There are two output parameters to chain/chain_prune, one is tree_page
the other is stable_node_dup.  Like in get_ksm_page the caller has to
check tree_page is NULL before touching the stable_node.  Similarly in
chain/chain_prune the caller has to check tree_page before touching the
stable_node_dup returned or the original stable_node passed as
parameter.

Because the tree_page is never returned as a stale pointer, it may be
more intuitive to return tree_page and to pass stable_node_dup for
reference instead of the reverse.

This patch purely swaps the two output parameters of chain/chain_prune
as a cleanup for the static checker and to mimic the get_ksm_page
behavior more closely.  There's no change to the caller at all except
the swap, it's purely a cleanup and it is a noop from the caller point
of view.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Andrea Arcangeli <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Tested-by: Dan Carpenter <[email protected]>
Cc: Evgheni Dereveanchin <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Petr Holasek <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Gavin Guo <[email protected]>
Cc: Jay Vosburgh <[email protected]>
Cc: Mel Gorman <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/ksm.c