]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: qla2xxx: Fix error handling in qlt_alloc_qfull_cmd()
authorBart Van Assche <bvanassche@acm.org>
Wed, 17 Apr 2019 21:44:27 +0000 (14:44 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit c04466c17142d5eb566984372b9a5003d1900fe3 ]

The test "if (!cmd)" is not useful because it is guaranteed that cmd !=
NULL.  Instead of testing the cmd pointer, rely on the tag to decide
whether or not command allocation failed.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Giridhar Malavali <gmalavali@marvell.com>
Fixes: 33e799775593 ("qla2xxx: Add support for QFull throttling and Term Exchange retry") # v3.18.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Himanshu Madhani <hmadhani@marvell.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_target.c

index 86f5e49caed81a2b3dedc9551d4d380b59a38f25..2654c482efc62e132bcad8d865fa6800e7c597f1 100644 (file)
@@ -5291,11 +5291,7 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host *vha,
        se_sess = sess->se_sess;
 
        tag = percpu_ida_alloc(&se_sess->sess_tag_pool, TASK_RUNNING);
-       if (tag < 0)
-               return;
-
-       cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag];
-       if (!cmd) {
+       if (tag < 0) {
                ql_dbg(ql_dbg_io, vha, 0x3009,
                        "qla_target(%d): %s: Allocation of cmd failed\n",
                        vha->vp_idx, __func__);
@@ -5310,6 +5306,7 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host *vha,
                return;
        }
 
+       cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag];
        memset(cmd, 0, sizeof(struct qla_tgt_cmd));
 
        qlt_incr_num_pend_cmds(vha);