Re: [CHECKER] Memory Leak on commonly executed path in jfs_link(JFS 2.4, kernel 2.4.19)

From: Dave Kleikamp
Date: Tue May 04 2004 - 13:12:07 EST


On Fri, 2004-04-30 at 17:31, Junfeng Yang wrote:
> get_UCSname is a memory allocation function. Should call
> free_UCSname(&dname) to free the allocated memory

I'm embarrassed to see how long this one has gone undetected. Here's a
patch. I'll send these to Marcelo and Linus after more complete
testing.

===== fs/jfs/namei.c 1.22 vs edited =====
--- 1.22/fs/jfs/namei.c Wed Mar 24 14:55:56 2004
+++ edited/fs/jfs/namei.c Tue May 4 12:54:00 2004
@@ -784,14 +784,14 @@
goto out;

if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE)))
- goto out;
+ goto free_dname;

/*
* create entry for new link in parent directory
*/
ino = ip->i_ino;
if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack)))
- goto out;
+ goto free_dname;

/* update object inode */
ip->i_nlink++; /* for new link */
@@ -803,6 +803,9 @@
iplist[0] = ip;
iplist[1] = dir;
rc = txCommit(tid, 2, &iplist[0], 0);
+
+ free_dname:
+ free_UCSname(&dname);

out:
txEnd(tid);

--
David Kleikamp
IBM Linux Technology Center

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/