diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index a360b24ed320..716175fc7d6e 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -749,6 +749,14 @@ int diWrite(tid_t tid, struct inode *ip) p = (dtpage_t *) &jfs_ip->i_dtroot; xp = (dtpage_t *) & dp->di_dtroot; lv = ilinelock->lv; + + /* Ensure the starting index and number of slots are within valid bounds */ + if (start_index >= 128 || num_slots > 128 || (start_index + num_slots) > 128) { + /* Handle the error appropriately, such as logging a warning or returning an error code */ + pr_warn("Invalid slot range: start_index=%u, num_slots=%u\n", start_index, num_slots); + return -EINVAL; + } + for (n = 0; n < ilinelock->index; n++, lv++) { memcpy(&xp->slot[lv->offset], &p->slot[lv->offset], lv->length << L2DTSLOTSIZE);