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=1796384058; b=UbF+YKkWrnP1jC49K0D1R2EmEJvczRVuOI6Rl4MlReOTtqbMcw+sXeLrMPc8DVU65SAm JggZnWFd1xLgfqNA+OLP+3uEIlZ3wEyWJJp+RU8JDyI4upiIjc+saLCktgVFEJDse5FpN M/MJQj+xB4r0fRdFuJurqdjcTSKS9xwmA9d4PbmeswXRfz8COkn7fWB2OVtJxuAAKwJcC JKO5YQewwZ/Hp8XjdMluVZYy/hjoAvRDrDEsM9MnMjwLWeHjVU/D/eCLEdcmqw3/8cd3M MNMaE5WPMwxWwRlFUFv71U/WM8dRp07J97GKYVFiHAbbCWmW2PPlGdCqILXmnL4QAjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384058; 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=YGqPd3JTeGrjvpkosS2scL0NS4s5M4rQzztkGZactc4=; b=PE21awVWoDELEN/QgQEK31FTXcHo2elyjhe+Wj5P5MhevSVZxEtBLTroezlbqZIZMvz3 k3nEgzSUur5QYyYYGlrG7weLg+e8FzMKsL9rPM/3I3ZmFyEHPWy9vkeARzHSYM/XVW5fz nx3dTsk3zo/FcYXViw6GT5QHgjJBg4hNGJyE51rHuMlIdSAjqwlN9xbiiyWi+Dx9mVugm sqx0MGaSl3hjR0wng9uwNoF4RavFC5oN+E0tx5vodGOxo4Wpg+xUM7d2WVGzAQVc127Es a1o0A3pmbgKedvBbghF85LQKJlwrvyYml2zuUt9JaPyRHIjegqcq1sU0dx9SMzt8TjA== 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=pZwB9YwN; 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 19791606A322; Fri, 4 Dec 2026 11:34:17 +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=pZwB9YwN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51C9C1F000C2; Fri, 4 Dec 2026 11:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384057; bh=YGqPd3JTeGrjvpkosS2scL0NS4s5M4rQzztkGZactc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pZwB9YwNivZKsuLCKkEGCKqIqjemZ8O775VS0+c+kmvDWToJmHSJBVhDfKPCCLBDK 6qcgeBjKV2I6WX/q2K33V3o0J8wAl0THEHmGLZ/bf0fOagfW30gzoaa8EG3MAhw1KQ MfF/gchdS64UDwCVyQYoX0STQgo+f3nykSxIAZgo= 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.12 477/555] nvme-loop: release the target request when SG setup fails Date: Fri, 4 Dec 2026 19:08:40 +0900 Message-ID: <20261204100627.380271960@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 @@ -158,6 +158,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; }