linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<linmiaohe@huawei.com>
Subject: [PATCH] mm/swap_slots.c: Remove unnecessary NULL pointer check
Date: Sat, 9 Jan 2021 03:09:43 -0500	[thread overview]
Message-ID: <20210109080943.34832-1-linmiaohe@huawei.com> (raw)

The cache->slots and cache->slots_ret is already checked before we try to
drain it. And kvfree can handle the NULL pointer itself. So remove the
NULL pointer check here.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/swap_slots.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/swap_slots.c b/mm/swap_slots.c
index 0357fbe70645..4cf99ce033d0 100644
--- a/mm/swap_slots.c
+++ b/mm/swap_slots.c
@@ -178,7 +178,7 @@ static void drain_slots_cache_cpu(unsigned int cpu, unsigned int type,
 		swapcache_free_entries(cache->slots + cache->cur, cache->nr);
 		cache->cur = 0;
 		cache->nr = 0;
-		if (free_slots && cache->slots) {
+		if (free_slots) {
 			kvfree(cache->slots);
 			cache->slots = NULL;
 		}
@@ -188,13 +188,12 @@ static void drain_slots_cache_cpu(unsigned int cpu, unsigned int type,
 		spin_lock_irq(&cache->free_lock);
 		swapcache_free_entries(cache->slots_ret, cache->n_ret);
 		cache->n_ret = 0;
-		if (free_slots && cache->slots_ret) {
+		if (free_slots) {
 			slots = cache->slots_ret;
 			cache->slots_ret = NULL;
 		}
 		spin_unlock_irq(&cache->free_lock);
-		if (slots)
-			kvfree(slots);
+		kvfree(slots);
 	}
 }
 
-- 
2.19.1



             reply	other threads:[~2021-01-09  8:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09  8:09 Miaohe Lin [this message]
2021-01-09 17:40 ` Matthew Wilcox
2021-01-14  2:34   ` Miaohe Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210109080943.34832-1-linmiaohe@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox