[Yaffs] [patch] Low memory edge-case assertion failure

Top Page
Attachments:
Message as email
+ (text/plain)
+ yaffs-lowmem-patch (text/plain)
Delete this message
Reply to this message
Author: Ross Younger
Date:  
To: yaffs
Subject: [Yaffs] [patch] Low memory edge-case assertion failure
Whilst doing some stress testing on a board with limited RAM, I tripped over
an assertion failure.

In yaffs_CreateNewObject, YAFFS would sometimes successfully
AllocateEmptyObject but not be able to allocate a new tnode, so GetTnode
returned 0. It would then immediately attempt to FreeObject, but the freshly
allocated object already has a parent so it hits the YBUG trap at line 1992
of yaffs_guts.c.

I attach a patch which fixes this assertion (and a similar case I spotted in
yaffs_MknodObject) by calling DoGenericObjectDeletion instead of FreeObject,
though it might instead be reasonable for AllocateEmptyObject to not try to
add the object to the rootDir or lostNFoundDir.


Ross

-- 
Embedded Software Engineer, eCosCentric Limited.
Barnwell House, Barnwell Drive, Cambridge CB5 8UU, UK.
Registered in England no. 4422071.                  www.ecoscentric.com

diff -r 4c69dad4a37c -r 069b6a04b180 packages/fs/yaffs/current/src/yaffs_guts.c
--- a/packages/fs/yaffs/current/src/yaffs_guts.c    Sun Oct 25 23:19:20 2009 +0000
+++ b/packages/fs/yaffs/current/src/yaffs_guts.c    Thu Oct 29 17:22:43 2009 +0000
@@ -2179,7 +2179,7 @@
     if (type == YAFFS_OBJECT_TYPE_FILE) {
         tn = yaffs_GetTnode(dev);
         if (!tn) {
-            yaffs_FreeObject(theObject);
+            yaffs_DoGenericObjectDeletion(theObject);
             return NULL;
         }
     }
@@ -2293,7 +2293,7 @@
     if (type == YAFFS_OBJECT_TYPE_SYMLINK) {
         str = yaffs_CloneString(aliasString);
         if (!str) {
-            yaffs_FreeObject(in);
+            yaffs_DoGenericObjectDeletion(in);
             return NULL;
         }
     }