Received: by 10.223.176.5 with SMTP id f5csp1035809wra; Fri, 2 Feb 2018 10:04:22 -0800 (PST) X-Google-Smtp-Source: AH8x224n4wg8by1VgZsNLhvy+Pp2GlGu1AwR0CCMHlB6iFwgJZgHzQFqwUgmPFYWgYXzqol6/OaD X-Received: by 10.98.153.2 with SMTP id d2mr41514095pfe.44.1517594661985; Fri, 02 Feb 2018 10:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594661; cv=none; d=google.com; s=arc-20160816; b=rir1yrEBUtmq1KC2Jt/rhF0npOIJb+j3o+QLBbfawx47YxUNTpsgVLQVgynWmzONmu Ysk/Uk3LoXz+MtHnmexUN6K8dMjmOoN1p6jN/B4pnP0gnQfjmskt3exa6KFhaIMCaNEG zx82WhG/a/p/emSrxu84ZmqESiUwu1vnwFm/or3vN6q+Uz+At52umjnYfIN/kGWArHBi uSBIEQex68acsWyM4VY6F/BjKYFUYgvNNPcwxqbHHKahPkDCnHsBkn8k2ejUCE+/QJOe 5BCcUsxW3owMzuArUrym6D0br2eEUYs4TSOm/+Hg0hItbzNNZhcFj4/i2kmJL0SHa9Ut 4OQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FBacvDJBmucTKRaorU/3fgJl5gkB3qhm2bNabkUEFu8=; b=KEOz0k3UfHCUGIUB8W/PqPVuCXOc92GUu/m2X7k1N2V8dciDrhAMFVvldc81C/iKNM y+kDIaYkRvWKwaNqop+gS6JQujq7L+garTpOtGKfGon43IEie0XkfZjKoL0daQNmI12Y jnEy5foz+u1ffxbT4uqkWnpYn8jc5ixE1YZB8PY07wff/2VnyAEEbgL+vC07c2TAP8pq 6VRRbQO4BAS6Ns8pn95PG2fqE0X4LsRv3kciYdeiHRQ+qpA/CX2iKCTW5wfaJp1vaGdv RZP89MRSwybsPPO+rEnAEzlLo9MbLM6I/3yA1tuXJhGDCXZHdIjx0qxezrdBm4HnyCev oWKA== ARC-Authentication-Results: i=1; mx.google.com; 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 g189si257458pfc.386.2018.02.02.10.04.07; Fri, 02 Feb 2018 10:04:21 -0800 (PST) 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; 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 S1753480AbeBBSCq (ORCPT + 99 others); Fri, 2 Feb 2018 13:02:46 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37858 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752981AbeBBRJR (ORCPT ); Fri, 2 Feb 2018 12:09:17 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EF3BDE5E; Fri, 2 Feb 2018 17:09:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Smart , Sagi Grimberg , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.14 051/156] nvmet-fc: correct ref counting error when deferred rcv used Date: Fri, 2 Feb 2018 17:57:12 +0100 Message-Id: <20180202140842.587695866@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Smart [ Upstream commit 619c62dcc62b957d17cccde2081cad527b020883 ] Whenever a cmd is received a reference is taken while looking up the queue. The reference is removed after the cmd is done as the iod is returned for reuse. The fod may be reused for a deferred (recevied but no job context) cmd. Existing code removes the reference only if the fod is not reused for another command. Given the fod may be used for one or more ios, although a reference was taken per io, it won't be matched on the frees. Remove the reference on every fod free. This pairs the references to each io. Signed-off-by: James Smart Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/fc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -532,15 +532,15 @@ nvmet_fc_free_fcp_iod(struct nvmet_fc_tg tgtport->ops->fcp_req_release(&tgtport->fc_target_port, fcpreq); + /* release the queue lookup reference on the completed IO */ + nvmet_fc_tgt_q_put(queue); + spin_lock_irqsave(&queue->qlock, flags); deferfcp = list_first_entry_or_null(&queue->pending_cmd_list, struct nvmet_fc_defer_fcp_req, req_list); if (!deferfcp) { list_add_tail(&fod->fcp_list, &fod->queue->fod_list); spin_unlock_irqrestore(&queue->qlock, flags); - - /* Release reference taken at queue lookup and fod allocation */ - nvmet_fc_tgt_q_put(queue); return; } @@ -759,6 +759,9 @@ nvmet_fc_delete_target_queue(struct nvme tgtport->ops->fcp_req_release(&tgtport->fc_target_port, deferfcp->fcp_req); + /* release the queue lookup reference */ + nvmet_fc_tgt_q_put(queue); + kfree(deferfcp); spin_lock_irqsave(&queue->qlock, flags);