overlayfs: fix ovl_get_redirect() error handling
PATCH 1/1 overlayfs: fix ovl_get_redirect() error handling
The newly introduced ovl_get_redirect() function returns an unintialized variable when kmalloc() fails:
fs/overlayfs/dir.c: In function ‘ovl_set_redirect’:fs/overlayfs/overlayfs.h:92:6: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
This makes it return -ENOMEM instead.
Fixes 496654b0792e ("ovl: redirect on rename-dir")
Signed-off-by Arnd Bergmann <[email protected]>
--- fs/overlayfs/dir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/overlayfs/dir.c +3 -1
@@ -798,8 +798,10 @@ static char *ovl_get_redirect(struct dentry *dentry, bool samedir) } buf =kmalloc (buflen,GFP_TEMPORARY ); -if (!buf) +if (!buf) { + ret =ERR_PTR (-ENOMEM ); goto out; + } buflen--; buf[buflen] ='\0' ;
Signature · 1 line
2.9.0