Skip to content

Commit 1dcf123

Browse files
bas-archembeddedcfriedt
authored andcommitted
fs/ext2: Fix NULL dereference when fs_stat queries root.
When fs_stat() queries the root / mountpoint it should return its root i_node but instead it tries to return the parent i_node which does not exist. Fix this by checking if parent is set otherwise return the root i_node. Fixes #94000. Signed-off-by: Bas van Loon <[email protected]>
1 parent 850050b commit 1dcf123

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

subsys/fs/ext2/ext2_ops.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,11 @@ static int ext2_stat(struct fs_mount_t *mountp, const char *path, struct fs_dire
598598
}
599599

600600
uint32_t offset = args.offset;
601-
struct ext2_inode *parent = args.parent;
602-
struct ext2_file dir = {.f_inode = parent, .f_off = offset};
601+
struct ext2_file dir = {.f_inode = args.parent ? args.parent : args.inode, .f_off = offset};
603602

604603
rc = ext2_get_direntry(&dir, entry);
605604

606-
ext2_inode_drop(parent);
605+
ext2_inode_drop(args.parent);
607606
ext2_inode_drop(args.inode);
608607
return rc;
609608
}

0 commit comments

Comments
 (0)