From patchwork Wed Apr 17 21:44:19 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: 10906213 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 747891390 for ; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61B142867C for ; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55F5428818; Wed, 17 Apr 2019 21:45:10 +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 EA1AE2867C for ; Wed, 17 Apr 2019 21:45:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387927AbfDQVpI (ORCPT ); Wed, 17 Apr 2019 17:45:08 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37465 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387577AbfDQVpH (ORCPT ); Wed, 17 Apr 2019 17:45:07 -0400 Received: by mail-pg1-f194.google.com with SMTP id e6so155184pgc.4 for ; Wed, 17 Apr 2019 14:45:06 -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=XprVmq3TTMZOtRS9jGDhC+TKlXs+IlZcKHfOr2E3Goo=; b=FOu74IGULPy75QrVseP+gjcEIywDRMttmJD9WNonQ+8j7crPPrwtlMeMZ60yrk8+ej qK4cfEZZrnumQQYujXtIt2snKcKAeYZwZRmYGd4BXpKeqiOCEuyoFzxKQ6MmVoM5xXxd m+jaEmQAJQ6RQpDd0yz2ZXpXukRfnlsr9psDSETy9C3nH/nNHnpO3Hvc1/Bd/s/Vu5UW jKHGyh0yWBghX7AUR/NtjMLncY+p/6ejS5iMONwa1MJq6ovn37oF+NN7J4yDgCaajSEg 03uq3TVRt+QcvMv3lYqEGc4M+LlkVSH6civFjN40aRjvo9VFDEoKTwPYOqMkaYy1uwtA B04Q== X-Gm-Message-State: APjAAAXgxgTE1RUcWYiHPPJx/7roklY6GwbNRIwmqkZVdM8zfHRZN0ZW QktOMy7+GlETbONnxHJfxV8= X-Google-Smtp-Source: APXvYqx0FVtEQKpipid7i0zHyZCyeS1PlMZsiaRd0DAUMsDBMSq9hO9PBE5Xrhru+/Ll8Jane5iFOg== X-Received: by 2002:a62:4554:: with SMTP id s81mr63962692pfa.66.1555537506236; Wed, 17 Apr 2019 14:45:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:05 -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 10/34] qla2xxx: Avoid that Coverity complains about dereferencing a NULL rport pointer Date: Wed, 17 Apr 2019 14:44:19 -0700 Message-Id: <20190417214443.243152-11-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 Since Coverity cannot know that rport != NULL in qla2xxx_queuecommand() and since there is code in that function that dereferences the rport pointer, modify qla2xxx_queuecommand() such that it fails SCSI commands if rport == NULL. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_os.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index a3561e461aa5..5cfdf0cc3846 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -859,7 +859,8 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) uint32_t tag; uint16_t hwq; - if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { + if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)) || + WARN_ON_ONCE(!rport)) { cmd->result = DID_NO_CONNECT << 16; goto qc24_fail_command; } @@ -982,7 +983,7 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, srb_t *sp; int rval; - rval = fc_remote_port_chkready(rport); + rval = rport ? fc_remote_port_chkready(rport) : FC_PORTSTATE_OFFLINE; if (rval) { cmd->result = rval; ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076,