yaffs-direct: Fix object leak caused by defered free
authorCharles Manning <cdhmanning@gmail.com>
Tue, 4 Mar 2014 01:04:00 +0000 (14:04 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Tue, 4 Mar 2014 01:04:00 +0000 (14:04 +1300)
commit413797fe98ba5f4ba219c8628273eea918eb8655
tree2068907768f92d303628c159bfdbb20dc26e3754
parent6014fce5c65757724aef9033f2a710da324f2523
yaffs-direct: Fix object leak caused by defered free

The change to dtest.c adds a test case that was leaking objects.
The change to yaffsfs.c fixes this.

This leak was triggered by sequences of the following form:

yaffs_open(file_name, ...); /* create obj */
...
yaffs_unlink(file_name);
yaffs_close(file_name);

When the file was closed, obj->my_inode was not NULL when yaffs_del_obj() is
called, therefore the object was not released properly.

The fix "unstitches" the object before the call to yaffs_del_obj(), so that
obj->my_inode is NULL and the object freeing is done correctly.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/test-framework/basic-tests/dtest.c
direct/yaffsfs.c