public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xfsprogs misc memory leaks
@ 2013-10-06  2:51 tinguely
  2013-10-06  2:51 ` [PATCH 1/2] xfsprogs: fix leak in xfs_log_recover_add_to_trans tinguely
  2013-10-06  2:51 ` [PATCH 2/2] xfs: fix memory leak in xfs_dir2_node_removename tinguely
  0 siblings, 2 replies; 3+ messages in thread
From: tinguely @ 2013-10-06  2:51 UTC (permalink / raw)
  To: xfs

Here are the xfsprog versions of the Coverity 134683 and 134681 found
leak patches. They are the same as the kernel except the file names.

--Mark.


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

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

* [PATCH 1/2] xfsprogs: fix leak in xfs_log_recover_add_to_trans
  2013-10-06  2:51 [PATCH 0/2] xfsprogs misc memory leaks tinguely
@ 2013-10-06  2:51 ` tinguely
  2013-10-06  2:51 ` [PATCH 2/2] xfs: fix memory leak in xfs_dir2_node_removename tinguely
  1 sibling, 0 replies; 3+ messages in thread
From: tinguely @ 2013-10-06  2:51 UTC (permalink / raw)
  To: xfs

[-- Attachment #1: xfsprogs-fix-memory-leak-in-xlog_recover_add_to_trans.patch --]
[-- Type: text/plain, Size: 781 bytes --]

Free the memory in error path of xlog_recover_add_to_trans().
Normally this memory is freed in recovery pass2, but is leaked
in the error path.

Signed-off-by: Mark Tinguely <tinguely@sgi.com>

---
Found by Coverity (134683).

 libxlog/xfs_log_recover.c |    1 +
 1 file changed, 1 insertion(+)

Index: b/libxlog/xfs_log_recover.c
===================================================================
--- a/libxlog/xfs_log_recover.c
+++ b/libxlog/xfs_log_recover.c
@@ -1131,6 +1131,7 @@ xlog_recover_add_to_trans(
 		"bad number of regions (%d) in inode log format",
 				  in_f->ilf_size);
 			ASSERT(0);
+			kmem_free(ptr);
 			return XFS_ERROR(EIO);
 		}
 


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

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

* [PATCH 2/2] xfs: fix memory leak in xfs_dir2_node_removename
  2013-10-06  2:51 [PATCH 0/2] xfsprogs misc memory leaks tinguely
  2013-10-06  2:51 ` [PATCH 1/2] xfsprogs: fix leak in xfs_log_recover_add_to_trans tinguely
@ 2013-10-06  2:51 ` tinguely
  1 sibling, 0 replies; 3+ messages in thread
From: tinguely @ 2013-10-06  2:51 UTC (permalink / raw)
  To: xfs

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

Fix the leak of memory in xfs_dir2_node_removename()
when xfs_dir2_leafn_remove() returns an error code.

Signed-off-by: Mark Tinguely <tinguely@sgi.com>
---
 Found by Coverity (134681).

 libxfs/xfs_dir2_node.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Index: b/libxfs/xfs_dir2_node.c
===================================================================
--- a/libxfs/xfs_dir2_node.c
+++ b/libxfs/xfs_dir2_node.c
@@ -2087,12 +2087,12 @@ xfs_dir2_node_lookup(
  */
 int						/* error */
 xfs_dir2_node_removename(
-	xfs_da_args_t		*args)		/* operation arguments */
+	struct xfs_da_args	*args)		/* operation arguments */
 {
-	xfs_da_state_blk_t	*blk;		/* leaf block */
+	struct xfs_da_state_blk	*blk;		/* leaf block */
 	int			error;		/* error return value */
 	int			rval;		/* operation return value */
-	xfs_da_state_t		*state;		/* btree cursor */
+	struct xfs_da_state	*state;		/* btree cursor */
 
 	trace_xfs_dir2_node_removename(args);
 
@@ -2104,19 +2104,18 @@ xfs_dir2_node_removename(
 	state->mp = args->dp->i_mount;
 	state->blocksize = state->mp->m_dirblksize;
 	state->node_ents = state->mp->m_dir_node_ents;
-	/*
-	 * Look up the entry we're deleting, set up the cursor.
-	 */
+
+	/* Look up the entry we're deleting, set up the cursor. */
 	error = xfs_da3_node_lookup_int(state, &rval);
 	if (error)
-		rval = error;
-	/*
-	 * Didn't find it, upper layer screwed up.
-	 */
+		goto out_free;
+
+	/* Didn't find it, upper layer screwed up. */
 	if (rval != EEXIST) {
-		xfs_da_state_free(state);
-		return rval;
+		error = rval;
+		goto out_free;
 	}
+
 	blk = &state->path.blk[state->path.active - 1];
 	ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
 	ASSERT(state->extravalid);
@@ -2127,7 +2126,7 @@ xfs_dir2_node_removename(
 	error = xfs_dir2_leafn_remove(args, blk->bp, blk->index,
 		&state->extrablk, &rval);
 	if (error)
-		return error;
+		goto out_free;
 	/*
 	 * Fix the hash values up the btree.
 	 */
@@ -2142,6 +2141,7 @@ xfs_dir2_node_removename(
 	 */
 	if (!error)
 		error = xfs_dir2_node_to_leaf(state);
+out_free:
 	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] 3+ messages in thread

end of thread, other threads:[~2013-10-06  2:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-06  2:51 [PATCH 0/2] xfsprogs misc memory leaks tinguely
2013-10-06  2:51 ` [PATCH 1/2] xfsprogs: fix leak in xfs_log_recover_add_to_trans tinguely
2013-10-06  2:51 ` [PATCH 2/2] xfs: fix memory leak in xfs_dir2_node_removename tinguely

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