]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - mm/swapfile.c
mm/swapfile.c: remove unnecessary out label in __swap_duplicate()
[mirror_ubuntu-hirsute-kernel.git] / mm / swapfile.c
index c4a613688a175c4cc0e3d9c045e56a4bbb10fe79..83df467e1135ccd88670836c724a40e3a825ca53 100644 (file)
@@ -2867,6 +2867,7 @@ late_initcall(max_swapfiles_check);
 static struct swap_info_struct *alloc_swap_info(void)
 {
        struct swap_info_struct *p;
+       struct swap_info_struct *defer = NULL;
        unsigned int type;
        int i;
 
@@ -2895,7 +2896,7 @@ static struct swap_info_struct *alloc_swap_info(void)
                smp_wmb();
                WRITE_ONCE(nr_swapfiles, nr_swapfiles + 1);
        } else {
-               kvfree(p);
+               defer = p;
                p = swap_info[type];
                /*
                 * Do not memset this entry: a racing procfs swap_next()
@@ -2908,6 +2909,7 @@ static struct swap_info_struct *alloc_swap_info(void)
                plist_node_init(&p->avail_lists[i], 0);
        p->flags = SWP_USED;
        spin_unlock(&swap_lock);
+       kvfree(defer);
        spin_lock_init(&p->lock);
        spin_lock_init(&p->cont_lock);
 
@@ -3443,11 +3445,11 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
        unsigned long offset;
        unsigned char count;
        unsigned char has_cache;
-       int err = -EINVAL;
+       int err;
 
        p = get_swap_device(entry);
        if (!p)
-               goto out;
+               return -EINVAL;
 
        offset = swp_offset(entry);
        ci = lock_cluster_or_swap_info(p, offset);
@@ -3494,7 +3496,6 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
 
 unlock_out:
        unlock_cluster_or_swap_info(p, ci);
-out:
        if (p)
                put_swap_device(p);
        return err;
@@ -3611,7 +3612,7 @@ int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask)
 
        ci = lock_cluster(si, offset);
 
-       count = si->swap_map[offset] & ~SWAP_HAS_CACHE;
+       count = swap_count(si->swap_map[offset]);
 
        if ((count & ~COUNT_CONTINUED) != SWAP_MAP_MAX) {
                /*