Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3422929ybt; Tue, 23 Jun 2020 01:46:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyBWIRKUQ7LA2mY4rYPBHFKsm67a3/1BgjkhMF/UW5v1IrbaBsUCq1lnTicoQFvP16BIVF X-Received: by 2002:a50:dacf:: with SMTP id s15mr16813241edj.136.1592901966013; Tue, 23 Jun 2020 01:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592901966; cv=none; d=google.com; s=arc-20160816; b=ztCB1e3pCkdchYJ/kg5cL5ShzEk6qLqWUDM/pFPlMRGmxG7bNoNmoekO28PMTKwF77 0cV4nDPdWRX2PH5ZVbKRfp+RAAAppHG74cqpE7XdaenIU5IZbHb40LI5UlASd+DkMsTP ZRrpTFS0RqEyTr7sllig7Iv28qol+OmYilCka+ETGaf+vKNIWlUJgxDk9/wfQwG2zZ6a XnBIa1M+V8JuarvEtaAZqfRprqM2SmDkK5Dtz5FNeATo/ddGajne3AdIIRZ8Qr4RN3ZK 6qNjJm068YDtOR4Pdy2f3fL5MHXX96I3X+KhtytK5c0hRsC+ZEXznvth4KKx2Y3n9dmQ eLcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:ironport-sdr:dkim-signature; bh=3qBFEw3x0r6bNqV2zJ7slaRDovv3TN5c1Z3S4iPJbGE=; b=gHBx5kVdfE7//W5PmMcJUdWRsQt/QhfQntjlVTooosNEnZopRZQQ+exhRccY/CAexV e4WAXT5SRp+OBP6538cyvPP5s6lDSwgVvuIUi8IlW5yPeWeO3STcw/a+fjpG33mWyT6U XdTbdjouqkUXNf3Rd4WHATz7WWz0tLuAcQRfVGLWPDTM3v0gaR+yfXW3CiWS9vYoa6e9 wmZ4ss9OOuIGe9QMu9T+EpbWGiFkJdUkystvvXXKiaRjyGtaSaYQx8xbcWN7CVmuHPaq ln+I+1jIz2qqsYbrHhiLaK7VcaTAkQCK4UdeCA5FjYzfs7QyLtl5xX3Uj/3UXrtGP17K LpKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=I+KDXaHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l61si1076edl.512.2020.06.23.01.45.42; Tue, 23 Jun 2020 01:46:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=I+KDXaHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731859AbgFWImD (ORCPT + 99 others); Tue, 23 Jun 2020 04:42:03 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:31545 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731732AbgFWImC (ORCPT ); Tue, 23 Jun 2020 04:42:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1592901722; x=1624437722; h=from:to:cc:subject:date:message-id:mime-version; bh=3qBFEw3x0r6bNqV2zJ7slaRDovv3TN5c1Z3S4iPJbGE=; b=I+KDXaHk8qzmM4YWLnmosg66/u+ecDEJi/vAahish6q+iirMaBG6Tmv5 JGtu8F0ZWS0Ce59LbdQMfAbkHVW9MwoJfGXGTQ3kKZNEtBm8MXbYGzjd+ +tHbRbU1RrISaA0aYu2t+AjJdfLMfE3S+YkPEQfHqy7hD860plWttsfKF 8=; IronPort-SDR: Uv0Wpq3QHiYDL0enQytvGY72Cv4qYs5ky+tluqLYQgCSLdCvjBeExqQt7PKw2WJXdaQgPDgDYM Llcx/+QowVHQ== X-IronPort-AV: E=Sophos;i="5.75,270,1589241600"; d="scan'208";a="39247947" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 23 Jun 2020 08:42:00 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-807d4a99.us-east-1.amazon.com (Postfix) with ESMTPS id B619BA1DCA; Tue, 23 Jun 2020 08:41:58 +0000 (UTC) Received: from EX13D31EUA001.ant.amazon.com (10.43.165.15) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Jun 2020 08:41:57 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.160.48) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Jun 2020 08:41:48 +0000 From: SeongJae Park To: , , CC: , , , , SeongJae Park Subject: [PATCH] scsi: lpfc: Avoid another null dereference in lpfc_sli4_hba_unset() Date: Tue, 23 Jun 2020 10:41:22 +0200 Message-ID: <20200623084122.30633-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.48] X-ClientProxiedBy: EX13D24UWB002.ant.amazon.com (10.43.161.159) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park Commit cdb42becdd40 ("scsi: lpfc: Replace io_channels for nvme and fcp with general hdw_queues per cpu") has introduced static checker warnings for potential null dereferences in 'lpfc_sli4_hba_unset()' and commit 1ffdd2c0440d ("scsi: lpfc: resolve static checker warning in lpfc_sli4_hba_unset") has tried to fix it. However, yet another potential null dereference is remaining. This commit fixes it. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Fixes: 1ffdd2c0440d ("scsi: lpfc: resolve static checker warning inlpfc_sli4_hba_unset") Fixes: cdb42becdd40 ("scsi: lpfc: Replace io_channels for nvme and fcp with general hdw_queues per cpu") Signed-off-by: SeongJae Park --- drivers/scsi/lpfc/lpfc_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 69a5249e007a..6637f84a3d1b 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -11878,7 +11878,8 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba) lpfc_sli4_xri_exchange_busy_wait(phba); /* per-phba callback de-registration for hotplug event */ - lpfc_cpuhp_remove(phba); + if (phba->pport) + lpfc_cpuhp_remove(phba); /* Disable PCI subsystem interrupt */ lpfc_sli4_disable_intr(phba); -- 2.17.1