make prepend_name() work correctly when called with negative *buflen
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 23 Mar 2014 04:28:40 +0000 (00:28 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Apr 2014 19:02:36 +0000 (12:02 -0700)
commitfa82051f97c1e81e44ae1517a4303db6ceba1e2b
tree7577b51903b553991dba123d3d21f21e0bf90338
parentabfabd98494dcba8cefe726a28c006be87b34d0c
make prepend_name() work correctly when called with negative *buflen

commit e825196d48d2b89a6ec3a8eff280098d2a78207e upstream.

In all callchains leading to prepend_name(), the value left in *buflen
is eventually discarded unused if prepend_name() has returned a negative.
So we are free to do what prepend() does, and subtract from *buflen
*before* checking for underflow (which turns into checking the sign
of subtraction result, of course).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/dcache.c