From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35799C433DB for ; Sat, 9 Jan 2021 08:11:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05B09239A4 for ; Sat, 9 Jan 2021 08:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726608AbhAIILC (ORCPT ); Sat, 9 Jan 2021 03:11:02 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:10427 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbhAIILC (ORCPT ); Sat, 9 Jan 2021 03:11:02 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DCXgc1LXfzj3wh; Sat, 9 Jan 2021 16:09:32 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Sat, 9 Jan 2021 16:10:07 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm/swap_slots.c: Remove unnecessary NULL pointer check Date: Sat, 9 Jan 2021 03:09:43 -0500 Message-ID: <20210109080943.34832-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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