From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6D4DC32AABA; Mon, 27 Oct 2025 18:52:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591140; cv=none; b=HggoZwfG2wkGEzilqxyWHmjpucG+x4bwEDKvGWJMGv+ZJi4a+GlWV3ntitVWmYK+LuTcL+2e9MVIQsQX4I13UjRDCe11+VnzWqlqNpB8gHIdPo0W0v432v4fVtJkYvsysycs4sG1npEGlzModX7QA+kno2jHfagLUxbvUNVPmAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591140; c=relaxed/simple; bh=T5S/4ORYrEbkN6ePlJXanKwAcumBpBd8bu31Is8xBEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EAI0p5N9N7OzPzVe2tJwLkCfxa2OvqqVcJoIoHIwE+2l1jI/07Rbx7hnBeam0tNiKf4nu1zNVzPp+CZsKyZOubVS83UMNUB6miVvDYqD5A3FSU2q29TJIKJoxXsK7jKpYaGJyO6BVA+e71eHUIZgxTkiT2lXb34lD/D6lAq91tQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kBnEj1D6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kBnEj1D6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C24A9C4CEF1; Mon, 27 Oct 2025 18:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761591140; bh=T5S/4ORYrEbkN6ePlJXanKwAcumBpBd8bu31Is8xBEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kBnEj1D6G0mDUZ7HEfLkud3t4voZEdcONt332HxrM291iZL/FPxU/DuvV0fi+JuhV QVlqMzr2AOqDZ6TBhTlXZ6qnEqTgSPT4wVl+3b5DW3o194fJB7K1d80Pm0/ouaImam ZWE6LgffNQ6e4sgOlcgIrJYDm1Eg0nsn2CaHFd3M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Donet Tom , David Hildenbrand , Oscar Salvador , Alison Schofield , Chris Mason , Danilo Krummrich , Dave Jiang , Hiroyouki Kamezawa , Joanthan Cameron , "Ritesh Harjani (IBM)" , "Yury Norov (NVIDIA)" , Zi Yan , Andrew Morton , Sasha Levin Subject: [PATCH 5.10 083/332] drivers/base/node: fix double free in register_one_node() Date: Mon, 27 Oct 2025 19:32:16 +0100 Message-ID: <20251027183526.810010391@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183524.611456697@linuxfoundation.org> References: <20251027183524.611456697@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Donet Tom [ Upstream commit 0efdedfa537eb534c251a5b4794caaf72cc55869 ] When device_register() fails in register_node(), it calls put_device(&node->dev). This triggers node_device_release(), which calls kfree(to_node(dev)), thereby freeing the entire node structure. As a result, when register_node() returns an error, the node memory has already been freed. Calling kfree(node) again in register_one_node() leads to a double free. This patch removes the redundant kfree(node) from register_one_node() to prevent the double free. Link: https://lkml.kernel.org/r/20250918054144.58980-1-donettom@linux.ibm.com Fixes: 786eb990cfb7 ("drivers/base/node: handle error properly in register_one_node()") Signed-off-by: Donet Tom Acked-by: David Hildenbrand Acked-by: Oscar Salvador Cc: Alison Schofield Cc: Chris Mason Cc: Danilo Krummrich Cc: Dave Jiang Cc: Greg Kroah-Hartman Cc: Hiroyouki Kamezawa Cc: Joanthan Cameron Cc: "Ritesh Harjani (IBM)" Cc: Yury Norov (NVIDIA) Cc: Zi Yan Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- drivers/base/node.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 735527922a3d3..f34ae036485e0 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -963,7 +963,6 @@ int __register_one_node(int nid) error = register_node(node_devices[nid], nid); if (error) { node_devices[nid] = NULL; - kfree(node); return error; } -- 2.51.0