mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] overlayfs: fix ovl_get_redirect() error handling
@ 2016-11-22 14:29 Arnd Bergmann
  0 siblings, 0 replies; only message in thread
From: Arnd Bergmann @ 2016-11-22 14:29 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Arnd Bergmann, Vivek Goyal, Andreas Gruenbacher, Al Viro,
	Konstantin Khlebnikov, Antonio Murdaca, Maxim Patlasov,
	linux-unionfs, linux-kernel

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 <arnd@arndb.de>
---
 fs/overlayfs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index bc7c62c7a72f..fb9fce0112f0 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -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';
-- 
2.9.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-11-22 14:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-22 14:29 [PATCH] overlayfs: fix ovl_get_redirect() error handling Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®