From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382687; b=n26Jpryo6HNxgb42bG6liV21R5j/4VNt8loVu/1D8t+6J5wNkrM+C0LAYRlyYgEuU8KJ sI5zjcz2kNjlkBezvaNt18Nllepb4auAJ/fGqSP6qSlCftnuA7pbJWYeSO5blKodoEPBr 8pgIzh2QCWOHh7y4QkxdjmB9FxI6Aesh4WY7wUC6j8yFJJ/IFd+3p2YdaWwApRry0UP4F sIQ5OchcxKMJOazDuV4ub2UFeYpV64NFRo7hzMWpCoaXPm7P8d0+h0rMIOgQoqE4JXLNd ezO7QcTbztUjHviqSur0FNjMkFF5TjOh9qFA6I6BVe9L52c0ng2R50WeraNwp/qt+2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382687; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=KZGTrxTJzQpbi/E4GKd4wSRXJI/qsr9SgeMaE7KD6Ig=; b=dVTY+sTD03XpAaPPle/fXqmIJCIqsXsv/RtmwLNCPhhruOXlvpdUdAL13AZ+PR1WInC3 2Qtw9ISittSoH8VCM9dn2CaslsNQjiWpP9JKSK1UBcqV9Z/E2D0P1NJxjBmSMq/TBZ046 wC4+8TKjGVM987nFekDPwmZJ0jwEYMppkXfMyAhk83f84827L9wZqzic6Zoaq6/pru146 gr2Q2N8OUwrAY2dFtjLP4cRcejtt2pIR/sbu/TswZeVaDePPcPnCn7yyW9JfI1Wmg/h4Q lj3RGp9WksvKkek6WcU41BBLAGapfEoBQtceMY/XaZ/sMxahPG3w2Sox9klpxV2T8jw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xGAp17nb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B25E606A322; Fri, 4 Dec 2026 11:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=xGAp17nb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 020091F0092C; Fri, 4 Dec 2026 11:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382687; bh=KZGTrxTJzQpbi/E4GKd4wSRXJI/qsr9SgeMaE7KD6Ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xGAp17nbQlGYB6P+CbFaqbPTbr9fyYFXi4Nzc4iFmpfQSq79K2NlZgf8S5Fh56VHM cKqEzsIBpGM7FEACqch5d6v0JsbHX4TM7r7r/Xfcch2LpWaVtE2n5hW3J5kIRZPlwX vU5XDxEgyCJlL5FRDGr91cwhNE+DkEpAGIQOPVw0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Shao Mingyin , Keith Busch Subject: [PATCH 6.18 561/703] nvme-loop: release the target request when SG setup fails Date: Fri, 4 Dec 2026 19:07:40 +0900 Message-ID: <20261204100642.698913755@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shao Mingyin commit f2937481c28033e10e8a29b8742a767e73c696df upstream. nvme_loop_queue_rq() calls nvmet_req_init(), which takes a reference on the submission queue percpu ref, pins the namespace and, for a reservation-enabled namespace, takes a per-controller PR reference. If sg_alloc_table_chained() then fails under memory pressure, the function returns BLK_STS_RESOURCE without calling nvmet_req_uninit(). blk-mq retries the same request and nvmet_req_init() overwrites req->ns and req->pc_ref, leaking the queue, namespace and PR references taken by the failed attempt each time this happens. Release the request before returning BLK_STS_RESOURCE. Fixes: 3a85a5de29ea ("nvme-loop: add a NVMe loopback host driver") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Shao Mingyin Signed-off-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/target/loop.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -159,6 +159,7 @@ static blk_status_t nvme_loop_queue_rq(s blk_rq_nr_phys_segments(req), iod->sg_table.sgl, NVME_INLINE_SG_CNT)) { nvme_cleanup_cmd(req); + nvmet_req_uninit(&iod->req); return BLK_STS_RESOURCE; }