From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08E63277026; Sat, 17 Oct 2026 16:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792256299; cv=none; b=ePjWdro7GMDFA/QgXwfoERMJs34RfB61p8w0GHl/BwjcZL0qeY27iNEUIbSblFzP7rVihMrEjDavMF3+nZ51Bf86pQ00SgaK2n3KVCteB3e0+HTISeuA48CNQeNqoaV36B3C48BiQFkIyEM3+FFRJOW4PugLqQEXy0KdWjwYJ7I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792256299; c=relaxed/simple; bh=pOJTkU7k03luMhIaAvmg6khakY/VnSZJxC1Yc8wUh3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lxsnlvY96VAfmDbqaW3iDIspHif86wQz/FuRz+ae3mJTd8hAt+hnQad0YpyJqaCnoKwIlRFRXWIM3ziJSrMQ6+NFu+EhxmS4yXdYcIRjskXIRL8n+BxIK+0PMpnpDYUqnLAMw68okfH95pdRbnmJPH33MpMrP3lDgjoJHhYwRKo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PGqg/cJV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="PGqg/cJV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5661B1F000C4; Sat, 17 Oct 2026 16:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792256297; bh=rNqiFBhFgR2pVY+wtBZP2TlaYuTxkRl/VeLxefslIk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PGqg/cJVwpVa/4tNkxMtMJ4Sg/VUX9Lq5YkQi6ATdYV/ASHH+jVWHqs/u9S16lgQd DXfC3qzMHw3yWBrWbCzG5SPw/Rl9TYW3n7ozwczzbYMRM1bCfoq/qVnlJ9o1rL+3zB 8UytH2Mk0lSBQ85kXt3kBJY6T5durH7mL8Cz4aCs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Julian Sun , Christoph Hellwig , Keith Busch , Sasha Levin Subject: [PATCH 6.6 0189/1674] nvmet: preserve device path on allocation failure Date: Sat, 17 Oct 2026 17:41:01 +0200 Message-ID: <20261017160436.004411062@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Julian Sun [ Upstream commit 2f271b812170d4cad578bae1f91db72f3c2e36e7 ] nvmet_ns_device_path_store() frees the old path before allocating its replacement, losing the existing configuration if allocation fails. Allocate the new path before freeing the old one. Fixes: a07b4970f464 ("nvmet: add a generic NVMe target") Signed-off-by: Julian Sun Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/configfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c index 384cd2b540d0c..b266ed13ab326 100644 --- a/drivers/nvme/target/configfs.c +++ b/drivers/nvme/target/configfs.c @@ -346,6 +346,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item, struct nvmet_subsys *subsys = ns->subsys; size_t len; int ret; + char *new_path = NULL; mutex_lock(&subsys->lock); ret = -EBUSY; @@ -357,12 +358,14 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item, if (!len) goto out_unlock; - kfree(ns->device_path); ret = -ENOMEM; - ns->device_path = kmemdup_nul(page, len, GFP_KERNEL); - if (!ns->device_path) + new_path = kmemdup_nul(page, len, GFP_KERNEL); + if (!new_path) goto out_unlock; + kfree(ns->device_path); + ns->device_path = new_path; + mutex_unlock(&subsys->lock); return count; -- 2.53.0