diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-09-05 11:55:52 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-09-12 12:05:01 +0200 |
commit | a45114ecc75ac63481e975511f4487cba54a2bad (patch) | |
tree | f35198e6aca1e99aeedbbada349b948b12814629 /fs | |
parent | 3f7b9c34671e07e75cfc41360e643677c251d594 (diff) | |
download | barebox-a45114ecc75ac63481e975511f4487cba54a2bad.tar.gz |
fs: ext4: ext_barebox: handle ext_get_inode() errors
Static analyzer laments ext_get_inode, which can fail not having its
failure condition checked. Fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220905095557.596891-28-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ext_barebox.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/fs/ext4/ext_barebox.c b/fs/ext4/ext_barebox.c index 8f318a49c0..6c7c9885c4 100644 --- a/fs/ext4/ext_barebox.c +++ b/fs/ext4/ext_barebox.c @@ -127,8 +127,8 @@ static struct dentry *ext_lookup(struct inode *dir, struct dentry *dentry, if (ino) { inode = ext_get_inode(dir->i_sb, ino); - - d_add(dentry, inode); + if (inode) + d_add(dentry, inode); } return NULL; @@ -218,6 +218,8 @@ struct inode *ext_get_inode(struct super_block *sb, int ino) node = container_of(inode, struct ext2fs_node, i); ret = ext4fs_read_inode(fs->data, ino, &node->inode); + if (ret) + return NULL; inode->i_ino = ino; inode->i_mode = le16_to_cpu(node->inode.mode); @@ -262,23 +264,27 @@ static int ext_probe(struct device_d *dev) ret = fsdev_open_cdev(fsdev); if (ret) - goto err_open; + goto err; fs->cdev = fsdev->cdev; ret = ext4fs_mount(fs); if (ret) - goto err_mount; + goto err; sb->s_op = &ext_ops; inode = ext_get_inode(sb, 2); + if (!inode) { + ret = -EINVAL; + goto err; + } + sb->s_root = d_make_root(inode); return 0; -err_mount: -err_open: +err: free(fs); return ret; |