Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3011083ybi; Mon, 17 Jun 2019 14:38:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHQcz/7SUyWTMYzscy4UleI5jGPB8bqrqxTQ2AKWCKnOsBO1ZjM4jVUDefC23qftbMEmTQ X-Received: by 2002:a17:90a:20a2:: with SMTP id f31mr1228665pjg.90.1560807497052; Mon, 17 Jun 2019 14:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807497; cv=none; d=google.com; s=arc-20160816; b=0YeCpGVKqpxDAJBzIgkac8vy15ktZoACPl1GKWIC/2WXFv5/CxELOi8ZHV91uFpPPC YjxD6YWtMRaMo4t5+1k7ivfLCUFmGtgGSvUuWqlOfgeNnx4JipdilXG96cmCYeKXGP+Z 8pnA/u7vqCKfcfbg7JnavgrfHu09+tNb/qU+DXjDjPX+cCLKn3kRG14lyueOis3jhBzB np2CjYB08kq8pnGQZtSQ3FobrFVBQ0yzAzVhSUmOft7Wmig7fL0s2N1GiADE3ee9CGc6 Kcow6mEx8BEcN9cXkbqBmlGOomeLZatVzW1E6crR5Y13cNH1FWTjkCAKj6RipEVHeMGE 4G1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+phHj7w0+1XSlHxVbv2Gsay26jc9T2HZXCv/8HpPhBI=; b=tOxmbzweMheBP8Zj2myGfYUfgFk8V1vNQoUilvpGoeHzFdZG4qP75ylHFMD1kdUWsX p6YFzaAZijDZV+cS57FdI5K699fVeJSk+U6XlDIdac0jVZKU2BhMSZatVAnnM9R3NM11 XRCslUoZOhnBWsivhKMwlKfxAHdmUmJgl6xFThL22cyESvqB+EscVeEw0eyQYI8rfydc QCMcG4AdOfCsghZBfg53wVeFua1F/ko8XXhIGzw1kMmsbUfqqKyzjVbymn5/tunT6TAs RCk2DXf++Hh60qfIYWpYyoQTfvSuJvSdAOvOXqltN37d1+R3MSLhAV0KxlYS5h2sRm3+ 5Psg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z0aixPSz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l70si395338pje.68.2019.06.17.14.38.01; Mon, 17 Jun 2019 14:38:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z0aixPSz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729206AbfFQVUv (ORCPT + 99 others); Mon, 17 Jun 2019 17:20:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:45150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728572AbfFQVUt (ORCPT ); Mon, 17 Jun 2019 17:20:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44A69208E4; Mon, 17 Jun 2019 21:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806447; bh=RtNJ1Kth8ANzdTosbUS09zVyeMovhsQcxEh0bfS9kQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z0aixPSzI/JMAm58LVu9wg7m3OnSqqKBNl7GpSBHQsH2iXhm/ZIBNFdrbYOjnV6ZC tUIlMh6oFAPLucW8qmPjDAf5m1HcFqKV/8ByPqeEsxRQONeT29age9QjaV26+iPQ+E fLcIPovFy0RC5t2VEIC6AYbbY2+SaoLimMZExjaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dick Kennedy , James Smart , Bart Van Assche , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.1 056/115] scsi: lpfc: correct rcu unlock issue in lpfc_nvme_info_show Date: Mon, 17 Jun 2019 23:09:16 +0200 Message-Id: <20190617210803.218158888@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 79080d349f7f58a2e86c56043a3d04184d5f294a ] Many of the exit cases were not releasing the rcu read lock. Corrected the exit paths. Signed-off-by: Dick Kennedy Signed-off-by: James Smart Tested-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_attr.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index f30cb0fb9a82..26a22e41204e 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -338,7 +338,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, phba->sli4_hba.io_xri_max, lpfc_sli4_get_els_iocb_cnt(phba)); if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; /* Port state is only one of two values for now. */ if (localport->port_id) @@ -354,7 +354,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, wwn_to_u64(vport->fc_nodename.u.wwn), localport->port_id, statep); if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { nrport = NULL; @@ -381,39 +381,39 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, /* Tab in to show lport ownership. */ if (strlcat(buf, "NVME RPORT ", PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; if (phba->brd_no >= 10) { if (strlcat(buf, " ", PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; } scnprintf(tmp, sizeof(tmp), "WWPN x%llx ", nrport->port_name); if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; scnprintf(tmp, sizeof(tmp), "WWNN x%llx ", nrport->node_name); if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; scnprintf(tmp, sizeof(tmp), "DID x%06x ", nrport->port_id); if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; /* An NVME rport can have multiple roles. */ if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR) { if (strlcat(buf, "INITIATOR ", PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; } if (nrport->port_role & FC_PORT_ROLE_NVME_TARGET) { if (strlcat(buf, "TARGET ", PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; } if (nrport->port_role & FC_PORT_ROLE_NVME_DISCOVERY) { if (strlcat(buf, "DISCSRVC ", PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; } if (nrport->port_role & ~(FC_PORT_ROLE_NVME_INITIATOR | FC_PORT_ROLE_NVME_TARGET | @@ -421,12 +421,12 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, scnprintf(tmp, sizeof(tmp), "UNKNOWN ROLE x%x", nrport->port_role); if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; } scnprintf(tmp, sizeof(tmp), "%s\n", statep); if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) - goto buffer_done; + goto rcu_unlock_buf_done; } rcu_read_unlock(); @@ -488,7 +488,13 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, atomic_read(&lport->cmpl_fcp_err)); strlcat(buf, tmp, PAGE_SIZE); -buffer_done: + /* RCU is already unlocked. */ + goto buffer_done; + + rcu_unlock_buf_done: + rcu_read_unlock(); + + buffer_done: len = strnlen(buf, PAGE_SIZE); if (unlikely(len >= (PAGE_SIZE - 1))) { -- 2.20.1