Re: [syzbot] [arm-msm?] [net?] memory leak in radix_tree_insert
From: syzbot
Date: Fri Dec 08 2023 - 04:45:48 EST
For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.
***
Subject: [arm-msm?] [net?] memory leak in radix_tree_insert
Author: lizhi.xu@xxxxxxxxxxxxx
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 33cc938e65a9
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 976b9bd02a1b..b98e9f2c24ac 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -55,6 +55,8 @@ struct kmem_cache *radix_tree_node_cachep;
#define IDR_MAX_PATH (DIV_ROUND_UP(IDR_INDEX_BITS, \
RADIX_TREE_MAP_SHIFT))
#define IDR_PRELOAD_SIZE (IDR_MAX_PATH * 2 - 1)
+static bool __radix_tree_delete(struct radix_tree_root *root,
+ struct radix_tree_node *node, void __rcu **slot);
/*
* Per-cpu pool of preloaded nodes
@@ -714,8 +716,10 @@ int radix_tree_insert(struct radix_tree_root *root, unsigned long index,
return error;
error = insert_entries(node, slot, item);
- if (error < 0)
+ if (error < 0) {
+ __radix_tree_delete(root, node, slot);
return error;
+ }
if (node) {
unsigned offset = get_slot_offset(node, slot);
--
2.43.0