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 859DB312812; Mon, 13 Oct 2025 15:41:03 +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=1760370063; cv=none; b=B2RqTv2GhssDahvyhd/rEFwatrg8T9qycR8YVgEIUtKjjCsD9mNDlCc4R5fhBwhvyyzoc26fkxwKRCIk7jOFAPjEZW1XGV24fhTrdcXrgUfmeA4kXrdxnyF623ua7hUFeaZNkwDQa1a3sdyhfxWzqr1Zdsd4Xtnq2/yWYAgRRhc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760370063; c=relaxed/simple; bh=/pJEl/i4RiNgxfpdFXiAf8AkpeiCaUxyLjLRhhnSOSs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C1fklthse/3rlVH19qdri3oVVDl6ZDkg46xbp+FkjwzttffL9uoqSof6+EitfQtEHSupHu93CQkUbaEA44MMauM83U1IuYvQzPNQQ1vdpum+3FIeYzdFZrue4IH8Fs4bF/nZPiZJbwyEANQOGhwNJZUkZJ3g1nOS+H7KOaAUq64= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k0er+Kt3; 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="k0er+Kt3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCFE3C4CEE7; Mon, 13 Oct 2025 15:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760370063; bh=/pJEl/i4RiNgxfpdFXiAf8AkpeiCaUxyLjLRhhnSOSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k0er+Kt3s0PtViiE7DdbgfMm2YmuTNi102gL7OsGYjn6AXpvaOzWTZCDDVuY/ny8+ 0ben1StWgce2v21jcZ1mdmOxRGcOOH89/VCjXTSxM8+5bFADW9e3ITrYNNZM3tsKK8 09DWEL8dUVn7r8fUrKSp3IGR8Vtc2IQfsUlONLx4= 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 6.17 466/563] drivers/base/node: fix double free in register_one_node() Date: Mon, 13 Oct 2025 16:45:27 +0200 Message-ID: <20251013144428.170614452@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013144411.274874080@linuxfoundation.org> References: <20251013144411.274874080@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.17-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 45d512939c408..67b01d5797377 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -887,7 +887,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