Bluetooth: Cancel the Sniff timer
[platform/kernel/linux-starfive.git] / fs / jfs / jfs_imap.c
index 923a584..eeedf60 100644 (file)
@@ -1320,7 +1320,7 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp)
 int diAlloc(struct inode *pip, bool dir, struct inode *ip)
 {
        int rc, ino, iagno, addext, extno, bitno, sword;
-       int nwords, rem, i, agno;
+       int nwords, rem, i, agno, dn_numag;
        u32 mask, inosmap, extsmap;
        struct inode *ipimap;
        struct metapage *mp;
@@ -1356,6 +1356,9 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
 
        /* get the ag number of this iag */
        agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb));
+       dn_numag = JFS_SBI(pip->i_sb)->bmap->db_numag;
+       if (agno < 0 || agno > dn_numag)
+               return -EIO;
 
        if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) {
                /*
@@ -2176,6 +2179,9 @@ static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)
        /* get the ag and iag numbers for this iag.
         */
        agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi);
+       if (agno >= MAXAG || agno < 0)
+               return -EIO;
+
        iagno = le32_to_cpu(iagp->iagnum);
 
        /* check if this is the last free extent within the