Skip to contentSkip to conversation

memory leak; allocated transaction not freed in xfs_inactive_free_eofblocks() in failure case.

PATCH RESEND In review Jesper Juhl 2 participants 2 messages Jun 30, 2007 – Jul 2, 2007 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 memory leak; allocated transaction not freed in xfs_inactive_free_eofblocks() in failure case.

(this is back from May 16 2007, resending since it doesn't look like the patch ever made it in anywhere)

Fix XFS memory leak; allocated transaction not freed in xfs_inactive_free_eofblocks() in failure case.

the code allocates a transaction, but in the case where 'truncate' is !=0 and xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, 0); happens to return an error, we'll just return from the function without dealing with the memory allocated byxfs_trans_alloc() and assigned to 'tp', thus it'll be orphaned/leaked - not good.

---

 fs/xfs/xfs_vnodeops.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/xfs/xfs_vnodeops.c +1 -0
index de17aed..32519cf 100644
@@ -1260,6 +1260,7 @@ xfs_inactive_free_eofblocks(
 		error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE,
 				    ip->i_size);
 		if (error) {
+			xfs_trans_cancel(tp, 0);
 			xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 			return error;
 		}
#1 lore raw
Quoted 4 lines · Jesper Juhl

(this is back from May 16 2007, resending since it doesn't look like the patch ever made it in anywhere)

Weird, looks like it's in cvs...

http://oss.sgi.com/cgi-bin/cvsweb.cgi/xfs-linux/xfs_vnodeops.c.diff?r1=text&tr1=1.699&r2=text&tr2=1.698&f=h

but not in git.

-Eric

Quoted 28 lines

Fix XFS memory leak; allocated transaction not freed in xfs_inactive_free_eofblocks() in failure case.

the code allocates a transaction, but in the case where 'truncate' is !=0 and xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, 0); happens to return an error, we'll just return from the function without dealing with the memory allocated byxfs_trans_alloc() and assigned to 'tp', thus it'll be orphaned/leaked - not good.

---

 fs/xfs/xfs_vnodeops.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/xfs/xfs_vnodeops.c +1 -0
index de17aed..32519cf 100644
@@ -1260,6 +1260,7 @@ xfs_inactive_free_eofblocks(
 		error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE,
 				    ip->i_size);
 		if (error) {
+			xfs_trans_cancel(tp, 0);
 			xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 			return error;
 		}