From 0a1d0dce3b2f84f7992828f3435ee3f292e79ad9 Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Wed, 4 Oct 2023 21:41:37 -0500 Subject: cpukit/jffs2: Correctly init jffs2_inode_info 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) -- cgit v1.2.3