[PATCH 1/4] cpukit/jffs2: Initialize and lock mutexes

Kinsey Moore kinsey.moore at oarcorp.com
Fri Mar 10 19:34:15 UTC 2023


Mutexes must be locked before they can be unlocked. JFFS2 doesn't
currently see this as an issue because all mutex operations are no-ops.
---
 cpukit/libfs/src/jffs2/src/dir-rtems.c | 2 ++
 cpukit/libfs/src/jffs2/src/fs-rtems.c  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/cpukit/libfs/src/jffs2/src/dir-rtems.c b/cpukit/libfs/src/jffs2/src/dir-rtems.c
index 9fa70bcec4..f9886c1266 100644
--- a/cpukit/libfs/src/jffs2/src/dir-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/dir-rtems.c
@@ -214,6 +214,8 @@ int jffs2_mknod(
 
 	f = JFFS2_INODE_INFO(inode);
 
+	mutex_lock(&f->sem);
+
 	inode->i_size = datalen;
 	ri->isize = ri->dsize = ri->csize = cpu_to_je32(inode->i_size);
 	ri->totlen = cpu_to_je32(sizeof(*ri) + inode->i_size);
diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c
index b863c74547..3be142a75f 100644
--- a/cpukit/libfs/src/jffs2/src/fs-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c
@@ -1459,6 +1459,7 @@ 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);
 }
 
 static void jffs2_clear_inode (struct _inode *inode)
@@ -1543,6 +1544,7 @@ static int jffs2_read_inode (struct _inode *inode)
 	c = JFFS2_SB_INFO(inode->i_sb);
 
 	jffs2_init_inode_info(f);
+	mutex_lock(&f->sem);
 	
 	ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node);
 
-- 
2.30.2



More information about the devel mailing list