Showing error 839

User: Jiri Slaby
Error type: Resource Leak
Error type description: The code omits to put the resource to the system for reuse
File location: lib/radix-tree.c
Line in file: 217
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:40:13 UTC


Source:

 187        node->count = 0;
 188
 189        kmem_cache_free(radix_tree_node_cachep, node);
 190}
 191
 192static inline void
 193radix_tree_node_free(struct radix_tree_node *node)
 194{
 195        call_rcu(&node->rcu_head, radix_tree_node_rcu_free);
 196}
 197
 198/*
 199 * Load up this CPU's radix_tree_node buffer with sufficient objects to
 200 * ensure that the addition of a single element in the tree cannot fail.  On
 201 * success, return zero, with preemption disabled.  On error, return -ENOMEM
 202 * with preemption not disabled.
 203 */
 204int radix_tree_preload(gfp_t gfp_mask)
 205{
 206        struct radix_tree_preload *rtp;
 207        struct radix_tree_node *node;
 208        int ret = -ENOMEM;
 209
 210        preempt_disable();
 211        rtp = &__get_cpu_var(radix_tree_preloads);
 212        while (rtp->nr < ARRAY_SIZE(rtp->nodes)) {
 213                preempt_enable();
 214                node = kmem_cache_alloc(radix_tree_node_cachep, gfp_mask);
 215                if (node == NULL)
 216                        goto out;
 217                preempt_disable();
 218                rtp = &__get_cpu_var(radix_tree_preloads);
 219                if (rtp->nr < ARRAY_SIZE(rtp->nodes))
 220                        rtp->nodes[rtp->nr++] = node;
 221                else
 222                        kmem_cache_free(radix_tree_node_cachep, node);
 223        }
 224        ret = 0;
 225out:
 226        return ret;
 227}
Show full sources