Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3008436ybi; Mon, 17 Jun 2019 14:34:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqznUtbxOGNwqw3sAIjJD0zw6DkjzOFSi9BT8IIl2PAlYH31hzSYoo1EUC+4nqhe8RQrvkmC X-Received: by 2002:a17:902:5ac4:: with SMTP id g4mr33662015plm.80.1560807270832; Mon, 17 Jun 2019 14:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807270; cv=none; d=google.com; s=arc-20160816; b=ci6XAcG46OxmFHNO+VAXH9FkVfYPJXacAwGN1tNHwKyQdHBvBCTf7S3yzetAeWv65s dyhrIpZQP9Z6k8hk+A3ajzITBDpdzzWVS6/tAc8ta74eturIK7GS4+/R2OtILD3+RFi2 q7zdP5oWXGM42sN94AOx6AiPO3hyzjnkyuOseGB+NOl7D/dv7B/cO4y8pDSNdWdx0tti SkIrK4OPFwd/r+hS05xnN2FO4YoS55bwRXuFRr352UJXgk6prJn4tNwR2/L6h17xJs72 3P88E/v42xyZsjFRnR5ZHnuMHWgVHPNbS7GekoKg0/NJUZ1p3X4w7b0f8Hjby1++nLks Tqdw== 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=jVVCwt2Y9Z0TnZSK3+6Yw0VUp3rF4Mvj9eR/b+6VpF0=; b=WLHxngSS8/EfRKClK/nze6rERY7ChdI2b0HgRlnm5WnwfitjkyozoNpPJs9dGgNXhl 3py4YxY8M9eoveJxD+8vZD45AZF0+3G7FQ3w+HdRKt4r5MiRh6x+CUBaIpnJpzfPAGg0 rkldoChF+0LyW0/SDn1CtgvY1oDTm1ovL5udw5b1Ek0ozz7FDZqOuTy/75Ou1qr8Idzd bo1V/eAovFZvxDNvv/kkMJld+E74FDt9WEg2iprzq5YFln4RY+DIXDMam3aPqwLvTYeC dtrucOxqZEdFa1XrBs/wInZ0szSKL/Qo9ZYDV9KaDIZ/1jYaoQa9wQsRax29D4TW71r9 JdSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cMKXJ30p; 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 i184si11380896pfb.123.2019.06.17.14.34.16; Mon, 17 Jun 2019 14:34:30 -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=cMKXJ30p; 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 S1730074AbfFQVZa (ORCPT + 99 others); Mon, 17 Jun 2019 17:25:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:51502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729693AbfFQVZZ (ORCPT ); Mon, 17 Jun 2019 17:25:25 -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 D69B920657; Mon, 17 Jun 2019 21:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806724; bh=fqkjKtFeCYJPAeyGJH6xJYw/kbvNAqSDYjsLukaKB+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cMKXJ30pqGrUeC32GXWDwUnx0MgMCcc43PuZ39vsOQV10j8XrI6ZodakmTapoApA6 NEdSbYA1jrUIwwpLA/j3d/Ds2vC2bbme7ccyFxQ2bVsY4kKA4fm/PqOhcDw9tZNw/J +RL/suq1k7wH/yiz7C+z7KhDhyB4mmNwtkSJyoww= 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 4.19 36/75] scsi: lpfc: correct rcu unlock issue in lpfc_nvme_info_show Date: Mon, 17 Jun 2019 23:09:47 +0200 Message-Id: <20190617210754.185875136@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210752.799453599@linuxfoundation.org> References: <20190617210752.799453599@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 cb19b12e7211..55cd96e2469c 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -341,7 +341,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, phba->sli4_hba.scsi_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) @@ -357,7 +357,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; @@ -384,39 +384,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 | @@ -424,12 +424,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(); @@ -491,7 +491,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