]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: qla2xxx: Move log messages before issuing command to firmware
authorGiridhar Malavali <giridhar.malavali@cavium.com>
Thu, 27 Sep 2018 05:05:18 +0000 (22:05 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Thu, 26 Sep 2019 04:34:52 +0000 (00:34 -0400)
BugLink: https://bugs.launchpad.net/bugs/1844558
[ Upstream commit 9fe278f44b4bc06cc61e33b2af65f87d507d13d0 ]

There is a probability that the SRB structure might have been released by the
time the debug log message dereferences it.  This patch moved the log messages
before the command is issued to the firmware to prevent unknown behavior and
kernel crash

Fixes: 726b85487067 ("qla2xxx: Add framework for async fabric discovery")
Cc: <stable@vger.kernel.org>
Signed-off-by: Giridhar Malavali <giridhar.malavali@cavium.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/scsi/qla2xxx/qla_gs.c
drivers/scsi/qla2xxx/qla_init.c

index c8cd785f192f7fee4f32408d87e7b4192e9b451b..1c140fc351d993df49cd117aa735fda5edf780d6 100644 (file)
@@ -3118,15 +3118,15 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport)
        sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
        sp->done = qla24xx_async_gpsc_sp_done;
 
-       rval = qla2x00_start_sp(sp);
-       if (rval != QLA_SUCCESS)
-               goto done_free_sp;
-
        ql_dbg(ql_dbg_disc, vha, 0x205e,
            "Async-%s %8phC hdl=%x loopid=%x portid=%02x%02x%02x.\n",
            sp->name, fcport->port_name, sp->handle,
            fcport->loop_id, fcport->d_id.b.domain,
            fcport->d_id.b.area, fcport->d_id.b.al_pa);
+
+       rval = qla2x00_start_sp(sp);
+       if (rval != QLA_SUCCESS)
+               goto done_free_sp;
        return rval;
 
 done_free_sp:
@@ -3453,13 +3453,14 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id)
        sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
        sp->done = qla2x00_async_gpnid_sp_done;
 
+       ql_dbg(ql_dbg_disc, vha, 0x2067,
+           "Async-%s hdl=%x ID %3phC.\n", sp->name,
+           sp->handle, ct_req->req.port_id.port_id);
+
        rval = qla2x00_start_sp(sp);
        if (rval != QLA_SUCCESS)
                goto done_free_sp;
 
-       ql_dbg(ql_dbg_disc, vha, 0x2067,
-           "Async-%s hdl=%x ID %3phC.\n", sp->name,
-           sp->handle, ct_req->req.port_id.port_id);
        return rval;
 
 done_free_sp:
index 2abf5b0b603563f4ce081fb109d845a71acc45cd..0b5d48e49a532cf1217fa9bf85f309f4239c55af 100644 (file)
@@ -198,11 +198,6 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
                goto done_free_sp;
        }
 
-       ql_dbg(ql_dbg_disc, vha, 0x2072,
-           "Async-login - %8phC hdl=%x, loopid=%x portid=%02x%02x%02x "
-               "retries=%d.\n", fcport->port_name, sp->handle, fcport->loop_id,
-           fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa,
-           fcport->login_retry);
        return rval;
 
 done_free_sp:
@@ -243,15 +238,16 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
        lio = &sp->u.iocb_cmd;
        lio->timeout = qla2x00_async_iocb_timeout;
        sp->done = qla2x00_async_logout_sp_done;
-       rval = qla2x00_start_sp(sp);
-       if (rval != QLA_SUCCESS)
-               goto done_free_sp;
 
        ql_dbg(ql_dbg_disc, vha, 0x2070,
            "Async-logout - hdl=%x loop-id=%x portid=%02x%02x%02x %8phC.\n",
            sp->handle, fcport->loop_id, fcport->d_id.b.domain,
                fcport->d_id.b.area, fcport->d_id.b.al_pa,
                fcport->port_name);
+
+       rval = qla2x00_start_sp(sp);
+       if (rval != QLA_SUCCESS)
+               goto done_free_sp;
        return rval;
 
 done_free_sp:
@@ -297,14 +293,16 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
        sp->done = qla2x00_async_adisc_sp_done;
        if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
                lio->u.logio.flags |= SRB_LOGIN_RETRIED;
-       rval = qla2x00_start_sp(sp);
-       if (rval != QLA_SUCCESS)
-               goto done_free_sp;
 
        ql_dbg(ql_dbg_disc, vha, 0x206f,
            "Async-adisc - hdl=%x loopid=%x portid=%02x%02x%02x.\n",
            sp->handle, fcport->loop_id, fcport->d_id.b.domain,
            fcport->d_id.b.area, fcport->d_id.b.al_pa);
+
+       rval = qla2x00_start_sp(sp);
+       if (rval != QLA_SUCCESS)
+               goto done_free_sp;
+
        return rval;
 
 done_free_sp:
@@ -596,6 +594,12 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
 
        sp->done = qla24xx_async_gnl_sp_done;
 
+       ql_dbg(ql_dbg_disc, vha, 0x2072,
+           "Async-login - %8phC hdl=%x, loopid=%x portid=%02x%02x%02x "
+               "retries=%d.\n", fcport->port_name, sp->handle, fcport->loop_id,
+           fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa,
+           fcport->login_retry);
+
        rval = qla2x00_start_sp(sp);
        if (rval != QLA_SUCCESS)
                goto done_free_sp;
@@ -830,14 +834,13 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
 
        sp->done = qla24xx_async_gpdb_sp_done;
 
-       rval = qla2x00_start_sp(sp);
-       if (rval != QLA_SUCCESS)
-               goto done_free_sp;
-
        ql_dbg(ql_dbg_disc, vha, 0x20dc,
            "Async-%s %8phC hndl %x opt %x\n",
            sp->name, fcport->port_name, sp->handle, opt);
 
+       rval = qla2x00_start_sp(sp);
+       if (rval != QLA_SUCCESS)
+               goto done_free_sp;
        return rval;
 
 done_free_sp:
@@ -1324,15 +1327,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun,
        tm_iocb->timeout = qla2x00_tmf_iocb_timeout;
        init_completion(&tm_iocb->u.tmf.comp);
 
-       rval = qla2x00_start_sp(sp);
-       if (rval != QLA_SUCCESS)
-               goto done_free_sp;
-
        ql_dbg(ql_dbg_taskm, vha, 0x802f,
            "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x.\n",
            sp->handle, fcport->loop_id, fcport->d_id.b.domain,
            fcport->d_id.b.area, fcport->d_id.b.al_pa);
 
+       rval = qla2x00_start_sp(sp);
+       if (rval != QLA_SUCCESS)
+               goto done_free_sp;
        wait_for_completion(&tm_iocb->u.tmf.comp);
 
        rval = tm_iocb->u.tmf.data;
@@ -1400,14 +1402,14 @@ qla24xx_async_abort_cmd(srb_t *cmd_sp)
        abt_iocb->timeout = qla24xx_abort_iocb_timeout;
        init_completion(&abt_iocb->u.abt.comp);
 
-       rval = qla2x00_start_sp(sp);
-       if (rval != QLA_SUCCESS)
-               goto done_free_sp;
-
        ql_dbg(ql_dbg_async, vha, 0x507c,
            "Abort command issued - hdl=%x, target_id=%x\n",
            cmd_sp->handle, fcport->tgt_id);
 
+       rval = qla2x00_start_sp(sp);
+       if (rval != QLA_SUCCESS)
+               goto done_free_sp;
+
        wait_for_completion(&abt_iocb->u.abt.comp);
 
        rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ?