yaffs Fix incorrect handling of deletion flag
authorCharles Manning <cdhmanning@gmail.com>
Thu, 13 May 2010 02:29:16 +0000 (14:29 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 13 May 2010 02:29:16 +0000 (14:29 +1200)
Move the reading of the deleted flag so that it picks up any changes.

Notw we need a value on the stack because the object might get
freed and we don't want to access a hanging pointer.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs_guts.c

index d55aa95b91e450758bf54474e047f7766100515f..9509dd401a33e5e9eb0a6989f74f733b1cc33d61 100644 (file)
@@ -5624,7 +5624,7 @@ static int yaffs_UnlinkFileIfNeeded(yaffs_Object *in)
 int yaffs_DeleteFile(yaffs_Object *in)
 {
        int retVal = YAFFS_OK;
-       int deleted = in->deleted;
+       int deleted; /* Need to cache value on stack if in is freed */
        yaffs_Device *dev = in->myDev;
 
        if (dev->param.disableSoftDelete || dev->param.isYaffs2)
@@ -5637,6 +5637,8 @@ int yaffs_DeleteFile(yaffs_Object *in)
                if (!in->unlinked)
                        retVal = yaffs_UnlinkFileIfNeeded(in);
 
+               deleted = in->deleted;
+
                if (retVal == YAFFS_OK && in->unlinked && !in->deleted) {
                        in->deleted = 1;
                        deleted = 1;