Skip to content

Commit fa96392

Browse files
Ranjan Kumarmartinkpetersen
authored andcommitted
scsi: mpi3mr: Add NULL checks when resetting request and reply queues
The driver encountered a crash during resource cleanup when the reply and request queues were NULL due to freed memory. This issue occurred when the creation of reply or request queues failed, and the driver freed the memory first, but attempted to mem set the content of the freed memory, leading to a system crash. Add NULL pointer checks for reply and request queues before accessing the reply/request memory during cleanup Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com> Link: https://patch.msgid.link/20260212070026.30263-1-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 5b31376 commit fa96392

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4806,21 +4806,25 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc)
48064806
}
48074807

48084808
for (i = 0; i < mrioc->num_queues; i++) {
4809-
mrioc->op_reply_qinfo[i].qid = 0;
4810-
mrioc->op_reply_qinfo[i].ci = 0;
4811-
mrioc->op_reply_qinfo[i].num_replies = 0;
4812-
mrioc->op_reply_qinfo[i].ephase = 0;
4813-
atomic_set(&mrioc->op_reply_qinfo[i].pend_ios, 0);
4814-
atomic_set(&mrioc->op_reply_qinfo[i].in_use, 0);
4815-
mpi3mr_memset_op_reply_q_buffers(mrioc, i);
4816-
4817-
mrioc->req_qinfo[i].ci = 0;
4818-
mrioc->req_qinfo[i].pi = 0;
4819-
mrioc->req_qinfo[i].num_requests = 0;
4820-
mrioc->req_qinfo[i].qid = 0;
4821-
mrioc->req_qinfo[i].reply_qid = 0;
4822-
spin_lock_init(&mrioc->req_qinfo[i].q_lock);
4823-
mpi3mr_memset_op_req_q_buffers(mrioc, i);
4809+
if (mrioc->op_reply_qinfo) {
4810+
mrioc->op_reply_qinfo[i].qid = 0;
4811+
mrioc->op_reply_qinfo[i].ci = 0;
4812+
mrioc->op_reply_qinfo[i].num_replies = 0;
4813+
mrioc->op_reply_qinfo[i].ephase = 0;
4814+
atomic_set(&mrioc->op_reply_qinfo[i].pend_ios, 0);
4815+
atomic_set(&mrioc->op_reply_qinfo[i].in_use, 0);
4816+
mpi3mr_memset_op_reply_q_buffers(mrioc, i);
4817+
}
4818+
4819+
if (mrioc->req_qinfo) {
4820+
mrioc->req_qinfo[i].ci = 0;
4821+
mrioc->req_qinfo[i].pi = 0;
4822+
mrioc->req_qinfo[i].num_requests = 0;
4823+
mrioc->req_qinfo[i].qid = 0;
4824+
mrioc->req_qinfo[i].reply_qid = 0;
4825+
spin_lock_init(&mrioc->req_qinfo[i].q_lock);
4826+
mpi3mr_memset_op_req_q_buffers(mrioc, i);
4827+
}
48244828
}
48254829

48264830
atomic_set(&mrioc->pend_large_data_sz, 0);

0 commit comments

Comments
 (0)