mm/swap_slots.c: simplify alloc_swap_slot_cache()
[linux-2.6-microblaze.git] / mm / swap_slots.c
index 0975adc..01609b5 100644 (file)
@@ -136,9 +136,16 @@ static int alloc_swap_slot_cache(unsigned int cpu)
 
        mutex_lock(&swap_slots_cache_mutex);
        cache = &per_cpu(swp_slots, cpu);
-       if (cache->slots || cache->slots_ret)
+       if (cache->slots || cache->slots_ret) {
                /* cache already allocated */
-               goto out;
+               mutex_unlock(&swap_slots_cache_mutex);
+
+               kvfree(slots);
+               kvfree(slots_ret);
+
+               return 0;
+       }
+
        if (!cache->lock_initialized) {
                mutex_init(&cache->alloc_lock);
                spin_lock_init(&cache->free_lock);
@@ -155,15 +162,8 @@ static int alloc_swap_slot_cache(unsigned int cpu)
         */
        mb();
        cache->slots = slots;
-       slots = NULL;
        cache->slots_ret = slots_ret;
-       slots_ret = NULL;
-out:
        mutex_unlock(&swap_slots_cache_mutex);
-       if (slots)
-               kvfree(slots);
-       if (slots_ret)
-               kvfree(slots_ret);
        return 0;
 }