]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
scsi: mpi3mr: Add NULL checks when resetting request and reply queues
authorRanjan Kumar <ranjan.kumar@broadcom.com>
Thu, 12 Feb 2026 07:00:26 +0000 (12:30 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 18 Feb 2026 02:31:47 +0000 (21:31 -0500)
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>
drivers/scsi/mpi3mr/mpi3mr_fw.c

index 1cfbdb77335387ce23d83f0227849aabbe880968..04d4a2aea7d726f954a1eba14ccd94b1c33d0b8c 100644 (file)
@@ -4806,21 +4806,25 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc)
        }
 
        for (i = 0; i < mrioc->num_queues; i++) {
-               mrioc->op_reply_qinfo[i].qid = 0;
-               mrioc->op_reply_qinfo[i].ci = 0;
-               mrioc->op_reply_qinfo[i].num_replies = 0;
-               mrioc->op_reply_qinfo[i].ephase = 0;
-               atomic_set(&mrioc->op_reply_qinfo[i].pend_ios, 0);
-               atomic_set(&mrioc->op_reply_qinfo[i].in_use, 0);
-               mpi3mr_memset_op_reply_q_buffers(mrioc, i);
-
-               mrioc->req_qinfo[i].ci = 0;
-               mrioc->req_qinfo[i].pi = 0;
-               mrioc->req_qinfo[i].num_requests = 0;
-               mrioc->req_qinfo[i].qid = 0;
-               mrioc->req_qinfo[i].reply_qid = 0;
-               spin_lock_init(&mrioc->req_qinfo[i].q_lock);
-               mpi3mr_memset_op_req_q_buffers(mrioc, i);
+               if (mrioc->op_reply_qinfo) {
+                       mrioc->op_reply_qinfo[i].qid = 0;
+                       mrioc->op_reply_qinfo[i].ci = 0;
+                       mrioc->op_reply_qinfo[i].num_replies = 0;
+                       mrioc->op_reply_qinfo[i].ephase = 0;
+                       atomic_set(&mrioc->op_reply_qinfo[i].pend_ios, 0);
+                       atomic_set(&mrioc->op_reply_qinfo[i].in_use, 0);
+                       mpi3mr_memset_op_reply_q_buffers(mrioc, i);
+               }
+
+               if (mrioc->req_qinfo) {
+                       mrioc->req_qinfo[i].ci = 0;
+                       mrioc->req_qinfo[i].pi = 0;
+                       mrioc->req_qinfo[i].num_requests = 0;
+                       mrioc->req_qinfo[i].qid = 0;
+                       mrioc->req_qinfo[i].reply_qid = 0;
+                       spin_lock_init(&mrioc->req_qinfo[i].q_lock);
+                       mpi3mr_memset_op_req_q_buffers(mrioc, i);
+               }
        }
 
        atomic_set(&mrioc->pend_large_data_sz, 0);