[PATCH] cpukit/jffs2: Avoid possible null deref

Kinsey Moore kinsey.moore at oarcorp.com
Wed Mar 22 21:25:22 UTC 2023


This was added with the writebuffer work and should have been protected
by the error check.
---
 cpukit/libfs/src/jffs2/src/fs-rtems.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c
index bff7d59ba1..9a0f4cb6f8 100644
--- a/cpukit/libfs/src/jffs2/src/fs-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c
@@ -1365,11 +1365,11 @@ int rtems_jffs2_initialize(
 		err = -ENOMEM;
 	}
 
-	sb = &fs_info->sb;
-	c = JFFS2_SB_INFO(sb);
-	c->mtd = NULL;
 
 	if (err == 0) {
+		sb = &fs_info->sb;
+		c = JFFS2_SB_INFO(sb);
+		c->mtd = NULL;
 		rtems_recursive_mutex_init(&sb->s_mutex, RTEMS_FILESYSTEM_TYPE_JFFS2);
 	}
 
-- 
2.30.2



More information about the devel mailing list