kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: Avoid some memory allocation
@ 2017-02-10 21:18 Christophe JAILLET
  2017-02-11 11:05 ` walter harms
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2017-02-10 21:18 UTC (permalink / raw)
  To: miklos; +Cc: linux-unionfs, linux-kernel, kernel-janitors, Christophe JAILLET

Reorder code to avoid allocating and then freeing some memory in an error
handling path.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 fs/overlayfs/namei.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 023bb0b03352..ba80ebb8a104 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -35,13 +35,13 @@ static int ovl_check_redirect(struct dentry *dentry, struct ovl_lookup_data *d,
 			return 0;
 		goto fail;
 	}
+	if (res = 0)
+		goto invalid;
+
 	buf = kzalloc(prelen + res + strlen(post) + 1, GFP_TEMPORARY);
 	if (!buf)
 		return -ENOMEM;
 
-	if (res = 0)
-		goto invalid;
-
 	res = vfs_getxattr(dentry, OVL_XATTR_REDIRECT, buf, res);
 	if (res < 0)
 		goto fail;
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-11 11:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-10 21:18 [PATCH] ovl: Avoid some memory allocation Christophe JAILLET
2017-02-11 11:05 ` walter harms

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).