Skip to content

Commit 1ec48f9

Browse files
committed
Pull jfs updates from Dave Kleikamp: "A couple bug fixes" * tag 'jfs-5.18' of https://github.com/kleikamp/linux-shaggy: jfs: prevent NULL deref in diFree jfs: fix divide error in dbNextAG
2 parents 1c24a18 + a530462 commit 1ec48f9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

fs/jfs/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ void jfs_evict_inode(struct inode *inode)
146146
dquot_initialize(inode);
147147

148148
if (JFS_IP(inode)->fileset == FILESYSTEM_I) {
149+
struct inode *ipimap = JFS_SBI(inode->i_sb)->ipimap;
149150
truncate_inode_pages_final(&inode->i_data);
150151

151152
if (test_cflag(COMMIT_Freewmap, inode))
152153
jfs_free_zero_link(inode);
153154

154-
if (JFS_SBI(inode->i_sb)->ipimap)
155+
if (ipimap && JFS_IP(ipimap)->i_imap)
155156
diFree(inode);
156157

157158
/*

fs/jfs/jfs_dmap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static const s8 budtab[256] = {
148148
* 0 - success
149149
* -ENOMEM - insufficient memory
150150
* -EIO - i/o error
151+
* -EINVAL - wrong bmap data
151152
*/
152153
int dbMount(struct inode *ipbmap)
153154
{
@@ -179,6 +180,12 @@ int dbMount(struct inode *ipbmap)
179180
bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
180181
bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
181182
bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag);
183+
if (!bmp->db_numag) {
184+
release_metapage(mp);
185+
kfree(bmp);
186+
return -EINVAL;
187+
}
188+
182189
bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel);
183190
bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag);
184191
bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref);

0 commit comments

Comments
 (0)