From patchwork Sat Mar 20 23:23:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12152777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CB2BC433C1 for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DBB861936 for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbhCTXYO (ORCPT ); Sat, 20 Mar 2021 19:24:14 -0400 Received: from mail-pj1-f48.google.com ([209.85.216.48]:55274 "EHLO mail-pj1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbhCTXYI (ORCPT ); Sat, 20 Mar 2021 19:24:08 -0400 Received: by mail-pj1-f48.google.com with SMTP id w8so6458129pjf.4 for ; Sat, 20 Mar 2021 16:24:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mrLK65kBn8v9kZOIAx6H1lvin4io4dky3juXy1Xbz6Q=; b=Uv4iBDlGKg/zw3L9vzI+Ej6Qen5jbczI8QY+zxz2yxstVbIF0zNqLHs5Tv/KR8Aa9g tt4nhJfWNuHVBOf47zB8nqFnIycqeSbeoxe9Rg4MxKyj74+dwTDlxS7LaOpnpOyGM+hi UYu0iV7+EL0kUUhaxhYZJaQ6SajZocZngKLrDorIA4HjAWwX0slAWMVBTP0/fvV8do6w 8ssV+iW1utaCBdONhClC0l/VQrn9/cRcOM4E9lh63+KWc1ccUbAgNbyN7m8RCZwC+a28 DQet3W7FZMXA5VVvlWqyNY35nUMI1xiWztDSihdxUVDhtiyl8P5dH+Tj+xnDnREDC6JK yDGw== X-Gm-Message-State: AOAM531zKjj4+I39RV870nB2cIHJsyoaIzfB56L2FSYGizIM+erdxIa9 6juVISYSwlpyaek8i/Iwn3A= X-Google-Smtp-Source: ABdhPJz9QX0watYIwwuPRW0z3Sus+RuYS0vPXMajzLfCrjfx7B4papeAhHlI3IljH9TdA+eWaTRfzg== X-Received: by 2002:a17:90a:ec15:: with SMTP id l21mr5459989pjy.164.1616282648260; Sat, 20 Mar 2021 16:24:08 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:9252:a76b:2952:3189]) by smtp.gmail.com with ESMTPSA id u7sm8869159pfh.150.2021.03.20.16.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 16:24:07 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Quinn Tran , Mike Christie , Daniel Wagner , Himanshu Madhani Subject: [PATCH v3 1/7] Revert "qla2xxx: Make sure that aborted commands are freed" Date: Sat, 20 Mar 2021 16:23:53 -0700 Message-Id: <20210320232359.941-2-bvanassche@acm.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210320232359.941-1-bvanassche@acm.org> References: <20210320232359.941-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Calling vha->hw->tgt.tgt_ops->free_cmd() from qlt_xmit_response() is wrong since the command for which a response is sent must remain valid until the SCSI target core calls .release_cmd(). It has been observed that the following scenario triggers a kernel crash: - qlt_xmit_response() calls qlt_check_reserve_free_req(). - qlt_check_reserve_free_req() returns -EAGAIN. - qlt_xmit_response() calls vha->hw->tgt.tgt_ops->free_cmd(cmd). - transport_handle_queue_full() tries to retransmit the response. Fix this crash by reverting the patch that introduced it. Fixes: 0dcec41acb85 ("scsi: qla2xxx: Make sure that aborted commands are freed") Cc: Quinn Tran Cc: Mike Christie Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 13 +++++-------- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 ---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 03a045f4e1b1..af5e6f4cb1a0 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3222,8 +3222,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) || (cmd->sess && cmd->sess->deleted)) { cmd->state = QLA_TGT_STATE_PROCESSED; - res = 0; - goto free; + return 0; } ql_dbg_qp(ql_dbg_tgt, qpair, 0xe018, @@ -3234,8 +3233,9 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, res = qlt_pre_xmit_response(cmd, &prm, xmit_type, scsi_status, &full_req_cnt); - if (unlikely(res != 0)) - goto free; + if (unlikely(res != 0)) { + return res; + } spin_lock_irqsave(qpair->qp_lock_ptr, flags); @@ -3255,8 +3255,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, vha->flags.online, qla2x00_reset_active(vha), cmd->reset_count, qpair->chip_reset); spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); - res = 0; - goto free; + return 0; } /* Does F/W have an IOCBs for this request */ @@ -3359,8 +3358,6 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, qlt_unmap_sg(vha, cmd); spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); -free: - vha->hw->tgt.tgt_ops->free_cmd(cmd); return res; } EXPORT_SYMBOL(qlt_xmit_response); diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 30959f8da065..15650a0bde09 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -653,7 +653,6 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) { struct qla_tgt_cmd *cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd); - struct scsi_qla_host *vha = cmd->vha; if (cmd->aborted) { /* Cmd can loop during Q-full. tcm_qla2xxx_aborted_task @@ -666,7 +665,6 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) cmd->se_cmd.transport_state, cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); - vha->hw->tgt.tgt_ops->free_cmd(cmd); return 0; } @@ -694,7 +692,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) { struct qla_tgt_cmd *cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd); - struct scsi_qla_host *vha = cmd->vha; int xmit_type = QLA_TGT_XMIT_STATUS; if (cmd->aborted) { @@ -708,7 +705,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) cmd, kref_read(&cmd->se_cmd.cmd_kref), cmd->se_cmd.transport_state, cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); - vha->hw->tgt.tgt_ops->free_cmd(cmd); return 0; } cmd->bufflen = se_cmd->data_length; From patchwork Sat Mar 20 23:23:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12152781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0C15C433E2 for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96DB46193C for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbhCTXYQ (ORCPT ); Sat, 20 Mar 2021 19:24:16 -0400 Received: from mail-pf1-f172.google.com ([209.85.210.172]:45824 "EHLO mail-pf1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhCTXYK (ORCPT ); Sat, 20 Mar 2021 19:24:10 -0400 Received: by mail-pf1-f172.google.com with SMTP id h3so8424545pfr.12 for ; Sat, 20 Mar 2021 16:24:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pICydD/oUCdcAvPVq02w89w/ZtGr0pZrWAsPFMD7kYk=; b=oWQu7IeUg6BXDrkzisM2IPbG/2iR8W/WDaLlFxlv+wmOZm34/3QH1pQKmgmugbkIxh z8St/80aH4guj2KlwCihQGJaOl3BgZ//59gyT7y1yncX9hmQG2nvax3sRLiOcYx5vGqq eRxcIeN3YrMmpRUwwlcP/Y0ubn8KPWgOO/fGRHYdnBtLHk+GS2FNBrasvHYZRKYFE1kk hlt4bD9L6GHS4HcQQXujVaV5hKsd/XKGgUmx/Yte5TfbnAptMIV2eMl8wFThJ7O368kH 5YSYbVjgPglYxEqBcIjMg10EweCZIsMYM2ms6KqJ46t3QmMbuAbz7tJmS2Yhz8wgTv/n k4pA== X-Gm-Message-State: AOAM530lqoAHwKSEMzNfZb0lP4Vo96Ldj4empLzSasTxdLFoLgLYChh9 RfjwxzI+FINMktXM/nlZGeU= X-Google-Smtp-Source: ABdhPJz4yPqnRwLq3/dBQTYu2991SgJiGoj7+Z6jmnDo2zhONwpmL3CtVMfBQ5IOhD+kIy3Iu/oBMg== X-Received: by 2002:a62:5f85:0:b029:204:99fa:3371 with SMTP id t127-20020a625f850000b029020499fa3371mr15352205pfb.1.1616282650012; Sat, 20 Mar 2021 16:24:10 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:9252:a76b:2952:3189]) by smtp.gmail.com with ESMTPSA id u7sm8869159pfh.150.2021.03.20.16.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 16:24:09 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Quinn Tran , Mike Christie , Daniel Wagner , Himanshu Madhani , Lee Duncan Subject: [PATCH v3 2/7] qla2xxx: Constify struct qla_tgt_func_tmpl Date: Sat, 20 Mar 2021 16:23:54 -0700 Message-Id: <20210320232359.941-3-bvanassche@acm.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210320232359.941-1-bvanassche@acm.org> References: <20210320232359.941-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since the target function pointers are not modified at runtime, declare the data structure with the target function pointers const. Cc: Quinn Tran Cc: Mike Christie Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani Reviewed-by: Lee Duncan Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 49b42b430df4..3bdf55bb0833 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -3815,7 +3815,7 @@ struct qlt_hw_data { __le32 __iomem *atio_q_in; __le32 __iomem *atio_q_out; - struct qla_tgt_func_tmpl *tgt_ops; + const struct qla_tgt_func_tmpl *tgt_ops; struct qla_tgt_vp_map *tgt_vp_map; int saved_set; diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 15650a0bde09..46111f031be9 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1578,7 +1578,7 @@ static void tcm_qla2xxx_update_sess(struct fc_port *sess, port_id_t s_id, /* * Calls into tcm_qla2xxx used by qla2xxx LLD I/O path. */ -static struct qla_tgt_func_tmpl tcm_qla2xxx_template = { +static const struct qla_tgt_func_tmpl tcm_qla2xxx_template = { .find_cmd_by_tag = tcm_qla2xxx_find_cmd_by_tag, .handle_cmd = tcm_qla2xxx_handle_cmd, .handle_data = tcm_qla2xxx_handle_data, From patchwork Sat Mar 20 23:23:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12152785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B18C2C433E0 for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 864386193A for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbhCTXYR (ORCPT ); Sat, 20 Mar 2021 19:24:17 -0400 Received: from mail-pj1-f41.google.com ([209.85.216.41]:42893 "EHLO mail-pj1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbhCTXYL (ORCPT ); Sat, 20 Mar 2021 19:24:11 -0400 Received: by mail-pj1-f41.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so6646593pjv.1 for ; Sat, 20 Mar 2021 16:24:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZIy6YnsiJ3Xs2uIxtZucjE2JC0EXqWKLMqKMxE5zEtc=; b=fe5kymHgO3DA2AymkKhKY17T4zkweFe4IGZd0DC8i3RJvz1IF2bMMHfRwl1LZwLsc/ PFesQSwyvhclrVA3hSfHT2b+jjpuX9TDHXiIi0MlsEsM71YGGTPK9JDoUwBHi+/jGHyS A8whda/AnY4t+EShBb9P6FWAIFW4mftFvSeFdcznY9jx7QYHvDr3GSL9vpk9w5DaeblL cAkUooIYmKOnO8PIHFpmYij1q6D8Llj2RIBMDpVADf5xTVY8C/pLtYCYK+uV0NrJc3EU xAU7TwvDaHenEaNO9pTwqZcUZtPeMI1bGb7y9DtjCsodrmMWOFIhn9n9rWa4FDaos13c 7ong== X-Gm-Message-State: AOAM5332qiRMYSu7BPnJcSmWGqLsnNm5bJryR8sTA+Cd2lBFLcoeR5d1 L2uELnBCu5uWZG3a7DMCe2g= X-Google-Smtp-Source: ABdhPJyNndDqvqdNwszN3TImUABK6QRFwur1zJ3Ny21R81iQyZModQCHFKgIsZN8HgScxvObW5Bcbw== X-Received: by 2002:a17:90a:fd0a:: with SMTP id cv10mr5381432pjb.167.1616282651499; Sat, 20 Mar 2021 16:24:11 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:9252:a76b:2952:3189]) by smtp.gmail.com with ESMTPSA id u7sm8869159pfh.150.2021.03.20.16.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 16:24:11 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Quinn Tran , Mike Christie , Daniel Wagner , Himanshu Madhani , Lee Duncan Subject: [PATCH v3 3/7] qla2xxx: Fix endianness annotations Date: Sat, 20 Mar 2021 16:23:55 -0700 Message-Id: <20210320232359.941-4-bvanassche@acm.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210320232359.941-1-bvanassche@acm.org> References: <20210320232359.941-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Fix all recently introduced endianness annotation issues. Cc: Quinn Tran Cc: Mike Christie Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani Reviewed-by: Lee Duncan Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/scsi/qla2xxx/qla_iocb.c | 3 ++- drivers/scsi/qla2xxx/qla_isr.c | 2 +- drivers/scsi/qla2xxx/qla_sup.c | 9 +++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 3bdf55bb0833..52ba75591f9a 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -1527,7 +1527,7 @@ struct init_sf_cb { * BIT_12 = Remote Write Optimization (1 - Enabled, 0 - Disabled) * BIT 11-0 = Reserved */ - uint16_t flags; + __le16 flags; uint8_t reserved1[32]; uint16_t discard_OHRB_timeout_value; uint16_t remote_write_opt_queue_num; diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index e765ee4ce162..c89e6d0f3616 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2379,7 +2379,8 @@ qla24xx_prli_iocb(srb_t *sp, struct logio_entry_24xx *logio) cpu_to_le32(NVME_PRLI_SP_FIRST_BURST); if (sp->vha->flags.nvme2_enabled) { /* Set service parameter BIT_7 for NVME CONF support */ - logio->io_parameter[0] |= NVME_PRLI_SP_CONF; + logio->io_parameter[0] |= + cpu_to_le32(NVME_PRLI_SP_CONF); /* Set service parameter BIT_8 for SLER support */ logio->io_parameter[0] |= cpu_to_le32(NVME_PRLI_SP_SLER); diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 27165abda96d..0fa7082f3cc8 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -3440,7 +3440,7 @@ qla24xx_abort_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, return; abt = &sp->u.iocb_cmd; - abt->u.abt.comp_status = le16_to_cpu(pkt->comp_status); + abt->u.abt.comp_status = pkt->comp_status; orig_sp = sp->cmd_sp; /* Need to pass original sp */ if (orig_sp) diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index f771fabcba59..060c89237777 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -2621,10 +2621,11 @@ qla24xx_read_optrom_data(struct scsi_qla_host *vha, void *buf, } static int -qla28xx_extract_sfub_and_verify(struct scsi_qla_host *vha, uint32_t *buf, +qla28xx_extract_sfub_and_verify(struct scsi_qla_host *vha, __le32 *buf, uint32_t len, uint32_t buf_size_without_sfub, uint8_t *sfub_buf) { - uint32_t *p, check_sum = 0; + uint32_t check_sum = 0; + __le32 *p; int i; p = buf + buf_size_without_sfub; @@ -2790,8 +2791,8 @@ qla28xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr, goto done; } - rval = qla28xx_extract_sfub_and_verify(vha, dwptr, dwords, - buf_size_without_sfub, (uint8_t *)sfub); + rval = qla28xx_extract_sfub_and_verify(vha, (__le32 *)dwptr, + dwords, buf_size_without_sfub, (uint8_t *)sfub); if (rval != QLA_SUCCESS) goto done; From patchwork Sat Mar 20 23:23:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12152783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1D63C433E1 for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B46956193B for ; Sat, 20 Mar 2021 23:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbhCTXYR (ORCPT ); Sat, 20 Mar 2021 19:24:17 -0400 Received: from mail-pl1-f177.google.com ([209.85.214.177]:37676 "EHLO mail-pl1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbhCTXYN (ORCPT ); Sat, 20 Mar 2021 19:24:13 -0400 Received: by mail-pl1-f177.google.com with SMTP id h20so4670973plr.4 for ; Sat, 20 Mar 2021 16:24:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ee5/Hwk/CNy9tnnYkU7iuKSqoOTwFuRXxBxJ32zQfKg=; b=oAM53hThA4xjCNHSHgv4zks9sibzglRe87l/FKEawPVjeZhKrwXDj34h7vVYvAkXYh XtZwCCuLH8ovxp0JSQlY4ocbrXMoteQq4s/hl+W1QrrxnJFLpUVmMFM1s4DVa4QNKonK 71/mG/ZFyIZHQ6i6FtJnZvQkjVWiMAm6M1A2YOriIsXmyP+qnwL1Hwoz86wr3ieKzgXT +f4GvhNzczyWNDlDszHdhaIo8uycLzR1kupmCHUbDmGtD+b1vFTv96myIIB9nX2eQi0a 7RWUpacHc5UEw+d4nx5eHhc1m7ZXPnGxwVNldjhjCl7FVUZzZ8wB7YSjNDUz6lTYI0Oa P3cQ== X-Gm-Message-State: AOAM5332bYCci4+vOCzSKwihFzvuQwRM49Dz+13N3Tl7EC75VDTZLCd6 Y+EOK+A2kK4zfcS/d5RA9BgmbhV0T5Q= X-Google-Smtp-Source: ABdhPJwqUlIRGWoxi1I37ZEXrKnnGcnc1Q1AiKdQ7hx9OHNqf3LIHZ/RINE3t3TwCFrWTb8mn+X+LA== X-Received: by 2002:a17:902:c1d5:b029:e6:52e0:6bdd with SMTP id c21-20020a170902c1d5b02900e652e06bddmr20459483plc.49.1616282653013; Sat, 20 Mar 2021 16:24:13 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:9252:a76b:2952:3189]) by smtp.gmail.com with ESMTPSA id u7sm8869159pfh.150.2021.03.20.16.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 16:24:12 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Quinn Tran , Mike Christie , Daniel Wagner , Himanshu Madhani , Lee Duncan Subject: [PATCH v3 4/7] qla2xxx: Suppress Coverity complaints about dseg_r* Date: Sat, 20 Mar 2021 16:23:56 -0700 Message-Id: <20210320232359.941-5-bvanassche@acm.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210320232359.941-1-bvanassche@acm.org> References: <20210320232359.941-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Change dseq_rq and dseg_rsp from scalar structure members into single-element arrays such that Coverity does not complain about the (*cur_dsd)++ statement in append_dsd64(). Cc: Quinn Tran Cc: Mike Christie Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani Reviewed-by: Lee Duncan Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_mr.c | 12 ++++++------ drivers/scsi/qla2xxx/qla_mr.h | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c index d488ae95e149..6e920da64863 100644 --- a/drivers/scsi/qla2xxx/qla_mr.c +++ b/drivers/scsi/qla2xxx/qla_mr.c @@ -3266,8 +3266,8 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.req_xfrcnt = cpu_to_le16(fxio->u.fxiocb.req_len); put_unaligned_le64(fxio->u.fxiocb.req_dma_handle, - &fx_iocb.dseg_rq.address); - fx_iocb.dseg_rq.length = + &fx_iocb.dseg_rq[0].address); + fx_iocb.dseg_rq[0].length = cpu_to_le32(fxio->u.fxiocb.req_len); } @@ -3276,8 +3276,8 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.rsp_xfrcnt = cpu_to_le16(fxio->u.fxiocb.rsp_len); put_unaligned_le64(fxio->u.fxiocb.rsp_dma_handle, - &fx_iocb.dseg_rsp.address); - fx_iocb.dseg_rsp.length = + &fx_iocb.dseg_rsp[0].address); + fx_iocb.dseg_rsp[0].length = cpu_to_le32(fxio->u.fxiocb.rsp_len); } @@ -3314,7 +3314,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) cpu_to_le16(bsg_job->request_payload.sg_cnt); tot_dsds = bsg_job->request_payload.sg_cnt; - cur_dsd = &fx_iocb.dseg_rq; + cur_dsd = &fx_iocb.dseg_rq[0]; avail_dsds = 1; for_each_sg(bsg_job->request_payload.sg_list, sg, tot_dsds, index) { @@ -3369,7 +3369,7 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.rsp_dsdcnt = cpu_to_le16(bsg_job->reply_payload.sg_cnt); tot_dsds = bsg_job->reply_payload.sg_cnt; - cur_dsd = &fx_iocb.dseg_rsp; + cur_dsd = &fx_iocb.dseg_rsp[0]; avail_dsds = 1; for_each_sg(bsg_job->reply_payload.sg_list, sg, diff --git a/drivers/scsi/qla2xxx/qla_mr.h b/drivers/scsi/qla2xxx/qla_mr.h index 73be8348402a..4f63aff333db 100644 --- a/drivers/scsi/qla2xxx/qla_mr.h +++ b/drivers/scsi/qla2xxx/qla_mr.h @@ -176,8 +176,12 @@ struct fxdisc_entry_fx00 { uint8_t flags; uint8_t reserved_1; - struct dsd64 dseg_rq; - struct dsd64 dseg_rsp; + /* + * Use array size 1 below to prevent that Coverity complains about + * the append_dsd64() calls for the two arrays below. + */ + struct dsd64 dseg_rq[1]; + struct dsd64 dseg_rsp[1]; __le32 dataword; __le32 adapid; From patchwork Sat Mar 20 23:23:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12152787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAD7DC433DB for ; Sat, 20 Mar 2021 23:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78DBA61937 for ; Sat, 20 Mar 2021 23:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbhCTXYw (ORCPT ); Sat, 20 Mar 2021 19:24:52 -0400 Received: from mail-pg1-f175.google.com ([209.85.215.175]:45612 "EHLO mail-pg1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbhCTXYP (ORCPT ); Sat, 20 Mar 2021 19:24:15 -0400 Received: by mail-pg1-f175.google.com with SMTP id n11so6154287pgm.12 for ; Sat, 20 Mar 2021 16:24:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=73EC2KzqpTqzE9VJFT6gqXuYYsYR6UX9nfEh/uhD7Ho=; b=lhsMJ90M+DNnwg5CNazCI/CvzVcjA8ekU6KNYwQ0/z12mXbSNn6lQv5yWwjCF5BpkO tmKzqHEFsPTkep4gKFiWBi7b+eBkuPlA3lNlb5qHqjm0GCXe4H1S0eYUKQygT1SCDbYd Seu/slXuDp4ajydqxVdv4q9vXNt9q+pfDkM4pWT09Ese1F1yAbIW/DB+LIOqw2YktPdY 6sQDvPlTRMz4Thnu3mtaT9ZGbY+U0Pncl7EvCeNIkKZcJjJDfAphTpswFDCbLMjBznf7 pcXqxfYPdCHklFbu6pUzDSCSe7I+YATTKP6VImGKDx+alKxjMfKAMlpdTEKtX/Y4te8I NJ/w== X-Gm-Message-State: AOAM532R+KFTXbJjJCTbSvf54wY9L81bOHOAInk55JVwq6lUF4yB7lfZ xct5nBWe4V7yfP9D14Xs5/Y= X-Google-Smtp-Source: ABdhPJypu4hmLWFlQkNiUJcna7ieYgbmE7YRtFz8Vq22WEa139M27Sd4AbqBt8Vhn39eDQgLJehhiA== X-Received: by 2002:a63:508:: with SMTP id 8mr2803872pgf.220.1616282654511; Sat, 20 Mar 2021 16:24:14 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:9252:a76b:2952:3189]) by smtp.gmail.com with ESMTPSA id u7sm8869159pfh.150.2021.03.20.16.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 16:24:14 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Quinn Tran , Mike Christie , Daniel Wagner , Himanshu Madhani , Lee Duncan Subject: [PATCH v3 5/7] qla2xxx: Simplify qla8044_minidump_process_control() Date: Sat, 20 Mar 2021 16:23:57 -0700 Message-Id: <20210320232359.941-6-bvanassche@acm.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210320232359.941-1-bvanassche@acm.org> References: <20210320232359.941-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch fixes the following Coverity complaint: CID 177490 (#1 of 1): Unused value (UNUSED_VALUE) assigned_value: Assigning value from opcode & 0xffffff7fU to opcode here, but that stored value is overwritten before it can be used. Cc: Quinn Tran Cc: Mike Christie Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani Reviewed-by: Lee Duncan Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_nx2.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nx2.c b/drivers/scsi/qla2xxx/qla_nx2.c index 7c413f93d53e..5ceecc9642fc 100644 --- a/drivers/scsi/qla2xxx/qla_nx2.c +++ b/drivers/scsi/qla2xxx/qla_nx2.c @@ -2226,19 +2226,16 @@ qla8044_minidump_process_control(struct scsi_qla_host *vha, if (opcode & QLA82XX_DBG_OPCODE_WR) { qla8044_wr_reg_indirect(vha, crb_addr, crb_entry->value_1); - opcode &= ~QLA82XX_DBG_OPCODE_WR; } if (opcode & QLA82XX_DBG_OPCODE_RW) { qla8044_rd_reg_indirect(vha, crb_addr, &read_value); qla8044_wr_reg_indirect(vha, crb_addr, read_value); - opcode &= ~QLA82XX_DBG_OPCODE_RW; } if (opcode & QLA82XX_DBG_OPCODE_AND) { qla8044_rd_reg_indirect(vha, crb_addr, &read_value); read_value &= crb_entry->value_2; - opcode &= ~QLA82XX_DBG_OPCODE_AND; if (opcode & QLA82XX_DBG_OPCODE_OR) { read_value |= crb_entry->value_3; opcode &= ~QLA82XX_DBG_OPCODE_OR; @@ -2249,7 +2246,6 @@ qla8044_minidump_process_control(struct scsi_qla_host *vha, qla8044_rd_reg_indirect(vha, crb_addr, &read_value); read_value |= crb_entry->value_3; qla8044_wr_reg_indirect(vha, crb_addr, read_value); - opcode &= ~QLA82XX_DBG_OPCODE_OR; } if (opcode & QLA82XX_DBG_OPCODE_POLL) { poll_time = crb_entry->crb_strd.poll_timeout; @@ -2269,7 +2265,6 @@ qla8044_minidump_process_control(struct scsi_qla_host *vha, crb_addr, &read_value); } } while (1); - opcode &= ~QLA82XX_DBG_OPCODE_POLL; } if (opcode & QLA82XX_DBG_OPCODE_RDSTATE) { @@ -2283,7 +2278,6 @@ qla8044_minidump_process_control(struct scsi_qla_host *vha, qla8044_rd_reg_indirect(vha, addr, &read_value); index = crb_entry->crb_ctrl.state_index_v; tmplt_hdr->saved_state_array[index] = read_value; - opcode &= ~QLA82XX_DBG_OPCODE_RDSTATE; } if (opcode & QLA82XX_DBG_OPCODE_WRSTATE) { @@ -2303,7 +2297,6 @@ qla8044_minidump_process_control(struct scsi_qla_host *vha, } qla8044_wr_reg_indirect(vha, addr, read_value); - opcode &= ~QLA82XX_DBG_OPCODE_WRSTATE; } if (opcode & QLA82XX_DBG_OPCODE_MDSTATE) { @@ -2316,7 +2309,6 @@ qla8044_minidump_process_control(struct scsi_qla_host *vha, read_value |= crb_entry->value_3; read_value += crb_entry->value_1; tmplt_hdr->saved_state_array[index] = read_value; - opcode &= ~QLA82XX_DBG_OPCODE_MDSTATE; } crb_addr += crb_entry->crb_strd.addr_stride; } From patchwork Sat Mar 20 23:23:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12152791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41BCAC433C1 for ; Sat, 20 Mar 2021 23:25:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D0476193B for ; Sat, 20 Mar 2021 23:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbhCTXYx (ORCPT ); Sat, 20 Mar 2021 19:24:53 -0400 Received: from mail-pg1-f171.google.com ([209.85.215.171]:46718 "EHLO mail-pg1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbhCTXYQ (ORCPT ); Sat, 20 Mar 2021 19:24:16 -0400 Received: by mail-pg1-f171.google.com with SMTP id e33so6162607pgm.13 for ; Sat, 20 Mar 2021 16:24:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yFAzczovREgLtzPFvwufMKeAL8tjwLLyNIaQjD0pczc=; b=fZNTYpZdzRkJL+Y156p71ItRVvWRJZURo7k+TeKNhhobvzpB4ykR7EjxpjUKdY2peQ uQ5aj6xqoy+AKI7t1U1uy/F9RhYyNV+h7ReAQ4u4qLz7k0h+bYcLdH7P4AwjlypUJ+dy tAziyFZSwXemsWw6bCYIZ/ypdrRXfYTClDi+ny5v/cRZunJyokunAsjOXTynq+1RwV9B +CqxTbHmbD7ZiaJ8M37iQ6diPCBhTiZ8P0AWta+XM3XQKEjIv473ydrRtr/NoJMGBuoJ 0KC7r2hUecjNw8qWH+RE/ytLjvUVAWsYioLF6CZgaUzDk3XOx6Rm0wY9s+atPaCDD3ZA 7/DA== X-Gm-Message-State: AOAM533TOgVdGgvi9WluyDPJdu/lHEcMQhA9EIrng0ynO2zZqfSdjaq3 e8prY93yQu2dyHJBdOO3C50= X-Google-Smtp-Source: ABdhPJydRJeivs3bUpeCMyxh2/zDIgXd9pMQ55PRJWHlueRbxo06Y+qENIlnxHkEdzPqg5ZjQEInUg== X-Received: by 2002:a63:db57:: with SMTP id x23mr16830861pgi.432.1616282656044; Sat, 20 Mar 2021 16:24:16 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:9252:a76b:2952:3189]) by smtp.gmail.com with ESMTPSA id u7sm8869159pfh.150.2021.03.20.16.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 16:24:15 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Quinn Tran , Mike Christie , Himanshu Madhani , Daniel Wagner , Lee Duncan Subject: [PATCH v3 6/7] qla2xxx: Always check the return value of qla24xx_get_isp_stats() Date: Sat, 20 Mar 2021 16:23:58 -0700 Message-Id: <20210320232359.941-7-bvanassche@acm.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210320232359.941-1-bvanassche@acm.org> References: <20210320232359.941-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch fixes the following Coverity warning: CID 361199 (#1 of 1): Unchecked return value (CHECKED_RETURN) 3. check_return: Calling qla24xx_get_isp_stats without checking return value (as is done elsewhere 4 out of 5 times). Cc: Quinn Tran Cc: Mike Christie Cc: Himanshu Madhani Cc: Daniel Wagner Cc: Lee Duncan Signed-off-by: Bart Van Assche Reviewed-by: Daniel Wagner Reviewed-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_attr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 63391c9be05d..3aa9869f6fae 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -2864,6 +2864,8 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost) vha->qla_stats.jiffies_at_last_reset = get_jiffies_64(); if (IS_FWI2_CAPABLE(ha)) { + int rval; + stats = dma_alloc_coherent(&ha->pdev->dev, sizeof(*stats), &stats_dma, GFP_KERNEL); if (!stats) { @@ -2873,7 +2875,11 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost) } /* reset firmware statistics */ - qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0); + rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0); + if (rval != QLA_SUCCESS) + ql_log(ql_log_warn, vha, 0x70de, + "Resetting ISP statistics failed: rval = %d\n", + rval); dma_free_coherent(&ha->pdev->dev, sizeof(*stats), stats, stats_dma); From patchwork Sat Mar 20 23:23:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 12152789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 322C8C433E0 for ; Sat, 20 Mar 2021 23:25:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F24D261937 for ; Sat, 20 Mar 2021 23:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbhCTXYy (ORCPT ); Sat, 20 Mar 2021 19:24:54 -0400 Received: from mail-pj1-f53.google.com ([209.85.216.53]:34542 "EHLO mail-pj1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbhCTXYS (ORCPT ); Sat, 20 Mar 2021 19:24:18 -0400 Received: by mail-pj1-f53.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so9741227pjb.1 for ; Sat, 20 Mar 2021 16:24:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VE1qmUCYp8cPGXujMeoDdARb9KpXb9/Fho8K3nlKaug=; b=PPgNNHLavJV1JM2U7zzN1wcgWlbdst4atwj9vj8w20iKH81VM7pTJ12I8h4mKKhr3q pltjn4boFLgQ+bsieqHswraVe6DDnBdTpEe99q50IhLVj25gtcyKVEaoq8XsLGSH+/HW y11ahRtdGmbVL1cIVkfHns6M0mL8h8J7ngiZPpFCqjHYNv///VOFXAz4SD3wjO9NlRmT gCY94JBKsqLbAYCDM1O/zwqz2rR3/mAK9MQ1/mXduuSAR3aJpfca2b3uDBxF+Aa9NENR HJCMYAZhnUIjDS3NBhxe+sZtRmWpn8QvVF1pUp+6vtfOLT0gCy+z5od6qg3XYE+c8UDk WtgQ== X-Gm-Message-State: AOAM531n5GlXBAhbRmxsTMlIJ+IRej1+N1Eww4Oboac8EOYwpiCBd14Q VI6CobcM8sxRM4gsXsVXMEM= X-Google-Smtp-Source: ABdhPJxcnV1g7tjlsqZPn0pssqD4b7wc2NWnkQIoEjTNt4ZFHPUX6gNXExDPdiW5NU38LPUcy2wZcQ== X-Received: by 2002:a17:90a:f40c:: with SMTP id ch12mr5540480pjb.176.1616282657676; Sat, 20 Mar 2021 16:24:17 -0700 (PDT) Received: from asus.hsd1.ca.comcast.net ([2601:647:4000:d7:9252:a76b:2952:3189]) by smtp.gmail.com with ESMTPSA id u7sm8869159pfh.150.2021.03.20.16.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 16:24:17 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Himanshu Madhani , Saurav Kashyap , Nilesh Javali , Quinn Tran , Mike Christie , Daniel Wagner , Lee Duncan Subject: [PATCH v3 7/7] qla2xxx: Check kzalloc() return value Date: Sat, 20 Mar 2021 16:23:59 -0700 Message-Id: <20210320232359.941-8-bvanassche@acm.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210320232359.941-1-bvanassche@acm.org> References: <20210320232359.941-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of crashing if kzalloc() fails, make qla2x00_get_host_stats() return -ENOMEM. Fixes: dbf1f53cfd23 ("scsi: qla2xxx: Implementation to get and manage host, target stats and initiator port") Cc: Himanshu Madhani Cc: Saurav Kashyap Cc: Nilesh Javali Cc: Quinn Tran Cc: Mike Christie Cc: Daniel Wagner Cc: Lee Duncan Signed-off-by: Bart Van Assche Reviewed-by: Daniel Wagner Acked-by: Saurav Kashyap Reviewed-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index bee8cf9f8123..bc84b2f389f8 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -2583,6 +2583,10 @@ qla2x00_get_host_stats(struct bsg_job *bsg_job) } data = kzalloc(response_len, GFP_KERNEL); + if (!data) { + kfree(req_data); + return -ENOMEM; + } ret = qla2xxx_get_ini_stats(fc_bsg_to_shost(bsg_job), req_data->stat_type, data, response_len);