From patchwork Wed Apr 17 21:44:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11BA01390 for ; Wed, 17 Apr 2019 21:45:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B6B28A93 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E62A628BAC; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C3528A96 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387791AbfDQVpT (ORCPT ); Wed, 17 Apr 2019 17:45:19 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33656 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387761AbfDQVpR (ORCPT ); Wed, 17 Apr 2019 17:45:17 -0400 Received: by mail-pg1-f194.google.com with SMTP id k19so164670pgh.0 for ; Wed, 17 Apr 2019 14:45: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=lugG6B8yBp/cm6LJRo01MraCQrLx2xInxC7bC//5+Mk=; b=tYv9Z0n8gZHoWmnYhlOIbVWxGofBXgl2au61luZNYsUVAHcYSRdQz2xn9rQXPaCmK2 8dVSLrjUkNBtT1Wyv/Gorc4hiMTg7ADwocjBV58Kr41+JxU9mHNtwVWp78KVrlbZoaWL 80Al5t48j+RE7ohPjY3XEMIQVAyHxHWDHmbS1N66IsiUJjA6Pr/4TDG2n8kajFsruBPG RfJwys2VXylbNBH77wZoHGo3b8ZvPPhEpY7diHJhw05BWv3nMp80LigfBmqZHrROJsNx nhRZXmFDbkHOdHUi4jJ+i4YP3vCU8fCUzMtIWQDiB8h9CBkzinmPtmHcv1HBIqBzucy8 fSAw== X-Gm-Message-State: APjAAAVFxGL5f3K7JGbtfbTllk5SHrrRiQ/PFZqZE5TGuG+r6Yecwi7v O/r5LVAsPYRuCrBJMsuiDuQ= X-Google-Smtp-Source: APXvYqxiiPebHiF8uzZ/q+Ouh+iNOp5S/h+WuG/JjEyW3RzisDTJX9MROCfPIBccfRK5F5T9cIL/ng== X-Received: by 2002:aa7:9389:: with SMTP id t9mr93312769pfe.60.1555537516365; Wed, 17 Apr 2019 14:45:16 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:15 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 18/34] qla2xxx: Fix error handling in qlt_alloc_qfull_cmd() Date: Wed, 17 Apr 2019 14:44:27 -0700 Message-Id: <20190417214443.243152-19-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Giridhar Malavali Fixes: 33e799775593 ("qla2xxx: Add support for QFull throttling and Term Exchange retry") # v3.18. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 69fc29d7e59d..144bdec9ddd2 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -5481,11 +5481,7 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host *vha, se_sess = sess->se_sess; tag = sbitmap_queue_get(&se_sess->sess_tag_pool, &cpu); - 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__); @@ -5500,6 +5496,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);