[PATCH 3/3] cpukit/jffs2: Correctly init jffs2_inode_info

Kinsey Moore kinsey.moore at oarcorp.com
Fri Oct 6 20:09:06 UTC 2023


The repeated reinitialization of jffs2_inode_info must be done by the
members of the struct to avoid altering others.
---
 cpukit/libfs/src/jffs2/src/fs-rtems.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c
index 0d97e7a6fb..8e8dfe8b0c 100644
--- a/cpukit/libfs/src/jffs2/src/fs-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c
@@ -1523,6 +1523,8 @@ static struct _inode *new_inode(struct super_block *sb)
 
 	inode->i_cache_next = NULL;	// Newest inode, about to be cached
 
+	mutex_init(&JFFS2_INODE_INFO(inode)->sem)
+
 	// Add to the icache
 	for (cached_inode = sb->s_root; cached_inode != NULL;
 	     cached_inode = cached_inode->i_cache_next) {
@@ -1639,8 +1641,14 @@ void jffs2_iput(struct _inode *i)
 
 static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
 {
-	memset(f, 0, sizeof(*f));
-	mutex_init(&f->sem);
+	/* These must be set manually to preserve other members */
+	f->highest_version = 0;
+	f->fragtree = RB_ROOT;
+	f->metadata = NULL;
+	f->dents = NULL;
+	f->target = NULL;
+	f->flags = 0;
+	f->usercompr = 0;
 }
 
 static void jffs2_clear_inode (struct _inode *inode)
-- 
2.39.2



More information about the devel mailing list