Skip to content

Commit bfa54d8

Browse files
donettom-1gregkh
authored andcommitted
drivers/base/node: fix double free in register_one_node()
[ Upstream commit 0efdedf ] 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/[email protected] Fixes: 786eb99 ("drivers/base/node: handle error properly in register_one_node()") Signed-off-by: Donet Tom <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Oscar Salvador <[email protected]> Cc: Alison Schofield <[email protected]> Cc: Chris Mason <[email protected]> Cc: Danilo Krummrich <[email protected]> Cc: Dave Jiang <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Hiroyouki Kamezawa <[email protected]> Cc: Joanthan Cameron <[email protected]> Cc: "Ritesh Harjani (IBM)" <[email protected]> Cc: Yury Norov (NVIDIA) <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 892f41e commit bfa54d8

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

drivers/base/node.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ int register_one_node(int nid)
887887
error = register_node(node_devices[nid], nid);
888888
if (error) {
889889
node_devices[nid] = NULL;
890-
kfree(node);
891890
return error;
892891
}
893892

0 commit comments

Comments
 (0)