public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix memory leak in xfs_dir2_node_removename
@ 2013-09-27 13:01 Mark Tinguely
  2013-09-27 13:08 ` Carlos Maiolino
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mark Tinguely @ 2013-09-27 13:01 UTC (permalink / raw)
  To: xfs

[-- Attachment #1: xfs-fix-leak-in-xfs_dir2_node_removename.patch --]
[-- Type: text/plain, Size: 1328 bytes --]

Free the memory pointed to by state before returning on error from 
xfs_dir2_node_removename.c

Signed-off-by: Mark Tinguely <tinguely@sgi.com>
---
Found by Coverity (134681) in userspace, same patch applies there
also.

 fs/xfs/xfs_dir2_node.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: b/fs/xfs/xfs_dir2_node.c
===================================================================
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -2131,10 +2131,9 @@ xfs_dir2_node_removename(
 	/*
 	 * Didn't find it, upper layer screwed up.
 	 */
-	if (rval != EEXIST) {
-		xfs_da_state_free(state);
-		return rval;
-	}
+	if (rval != EEXIST)
+		goto done;
+
 	blk = &state->path.blk[state->path.active - 1];
 	ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
 	ASSERT(state->extravalid);
@@ -2145,7 +2144,7 @@ xfs_dir2_node_removename(
 	error = xfs_dir2_leafn_remove(args, blk->bp, blk->index,
 		&state->extrablk, &rval);
 	if (error)
-		return error;
+		goto done;
 	/*
 	 * Fix the hash values up the btree.
 	 */
@@ -2160,6 +2159,7 @@ xfs_dir2_node_removename(
 	 */
 	if (!error)
 		error = xfs_dir2_node_to_leaf(state);
+done:
 	xfs_da_state_free(state);
 	return error;
 }


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2013-09-27 20:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-27 13:01 [PATCH] xfs: fix memory leak in xfs_dir2_node_removename Mark Tinguely
2013-09-27 13:08 ` Carlos Maiolino
2013-09-27 16:44 ` Eric Sandeen
2013-09-27 17:48   ` Mark Tinguely
2013-09-27 17:55     ` Eric Sandeen
2013-09-27 19:36 ` Roger Willcocks
2013-09-27 19:52   ` Mark Tinguely
2013-09-27 20:04   ` Eric Sandeen

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