diff mbox series

[050/200] mm/swapfile.c: remove unnecessary out label in __swap_duplicate()

Message ID 20201215030604.qIS1-P8T6%akpm@linux-foundation.org (mailing list archive)
State New, archived
Headers show
Series [001/200] kthread: add kthread_work tracepoints | expand

Commit Message

Andrew Morton Dec. 15, 2020, 3:06 a.m. UTC
From: Miaohe Lin <linmiaohe@huawei.com>
Subject: mm/swapfile.c: remove unnecessary out label in __swap_duplicate()

When the code went to the out label, it must have p == NULL.  So what out
label really does is redundant if check and return err.  We should Remove
this unnecessary out label because it does not handle resource free and so

Link: https://lkml.kernel.org/r/20201009130337.29698-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

 mm/swapfile.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series


--- a/mm/swapfile.c~mm-swapfilec-remove-unnecessary-out-label-in-__swap_duplicate
+++ a/mm/swapfile.c
@@ -3445,11 +3445,11 @@  static int __swap_duplicate(swp_entry_t
 	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);
@@ -3496,7 +3496,6 @@  static int __swap_duplicate(swp_entry_t
 	unlock_cluster_or_swap_info(p, ci);
 	if (p)
 	return err;