summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-06 16:07:27 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-06 16:07:27 +0000
commitf922c0b476868df9638acf9f420ddb2b4f8175e4 (patch)
treebe9bbeb246bf4918050ac839f666f124aeb27728
parent839d1a95e19a7442ad8f3964e6ec54e407ae9f25 (diff)
downloadnuttx-f922c0b476868df9638acf9f420ddb2b4f8175e4.tar.gz
nuttx-f922c0b476868df9638acf9f420ddb2b4f8175e4.tar.bz2
nuttx-f922c0b476868df9638acf9f420ddb2b4f8175e4.zip
Fix an NXFFS memory leak
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3570 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/fs/nxffs/nxffs_unlink.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/nuttx/fs/nxffs/nxffs_unlink.c b/nuttx/fs/nxffs/nxffs_unlink.c
index f75d98f28..f2295a966 100644
--- a/nuttx/fs/nxffs/nxffs_unlink.c
+++ b/nuttx/fs/nxffs/nxffs_unlink.c
@@ -103,7 +103,8 @@ int nxffs_rminode(FAR struct nxffs_volume_s *volume, FAR const char *name)
/* We can't remove the inode if it is open */
fdbg("Inode '%s' is open\n", name);
- return -EBUSY;
+ ret = -EBUSY;
+ goto errout;
}
/* Find the NXFFS inode */
@@ -112,7 +113,7 @@ int nxffs_rminode(FAR struct nxffs_volume_s *volume, FAR const char *name)
if (ret < 0)
{
fdbg("Inode '%s' not found\n", name);
- return ret;
+ goto errout;
}
/* Set the position to the FLASH offset of the file header (nxffs_findinode
@@ -127,7 +128,7 @@ int nxffs_rminode(FAR struct nxffs_volume_s *volume, FAR const char *name)
if (ret < 0)
{
fdbg("Failed to read data into cache: %d\n", ret);
- return ret;
+ goto errout_with_entry;
}
/* Change the file status... it is no longer valid */
@@ -141,10 +142,12 @@ int nxffs_rminode(FAR struct nxffs_volume_s *volume, FAR const char *name)
if (ret < 0)
{
fdbg("Failed to read data into cache: %d\n", ret);
- return ret;
}
- return OK;
+errout_with_entry:
+ nxffs_freeentry(&entry);
+errout:
+ return ret;
}
/****************************************************************************