summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-08-10 12:31:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-08-20 14:35:38 +0200
commit7b58c2f2d1a8dd370fc57a5c6457e9fa64cbdf80 (patch)
tree54a4e692439ec9c2fc236c069efea06b805fb8d7 /fs
parent07a7a6ce22ea0bbbb41252c018d83ae68f76df34 (diff)
downloadbarebox-7b58c2f2d1a8dd370fc57a5c6457e9fa64cbdf80.tar.gz
barebox-7b58c2f2d1a8dd370fc57a5c6457e9fa64cbdf80.tar.xz
fs: Use iget_locked() rather than squashfs specific function
Use iget_locked() to let the core allocate the inode. This properly initializes all fields in the new inode, especially it adds the new inode to the list of all inodes for the filesystem. This prevents a NULL pointer derefence when iput() removes the inode from that list. This fixes squashfs support which is broken since 43902e5763 ("fs: free inodes we no longer need") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/squashfs/inode.c18
-rw-r--r--fs/squashfs/squashfs.h1
2 files changed, 1 insertions, 18 deletions
diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index 470536e589..64155d47db 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -44,22 +44,6 @@
#include "squashfs_fs_i.h"
#include "squashfs.h"
-struct inode *iget_locked_squashfs(struct super_block *sb, unsigned long ino)
-{
- struct inode *inode;
- struct squashfs_inode_info *ei;
-
- ei = malloc(sizeof(struct squashfs_inode_info));
- inode = &ei->vfs_inode;
- if (inode) {
- inode->i_ino = ino;
- inode->i_sb = sb;
- inode->i_state = I_SYNC | I_NEW;
- }
-
- return inode;
-}
-
/*
* Initialise VFS inode with the base inode information common to all
* Squashfs inode types. Sqsh_ino contains the unswapped base inode
@@ -94,7 +78,7 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
struct inode *squashfs_iget(struct super_block *sb, long long ino,
unsigned int ino_number)
{
- struct inode *inode = iget_locked_squashfs(sb, ino_number);
+ struct inode *inode = iget_locked(sb, ino_number);
int err;
TRACE("Entered squashfs_iget\n");
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
index 31c9bc454e..825df2aedd 100644
--- a/fs/squashfs/squashfs.h
+++ b/fs/squashfs/squashfs.h
@@ -52,7 +52,6 @@ static inline struct squashfs_page *squashfs_page(struct page *page)
#define WARNING(s, args...) pr_warn("SQUASHFS: "s, ## args)
-struct inode *iget_locked_squashfs(struct super_block *sb, unsigned long ino);
char *squashfs_devread(struct squashfs_sb_info *fs, int byte_offset,
int byte_len);
extern int squashfs_mount(struct fs_device_d *fsdev,