From patchwork Wed Jan 20 07:27:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 12031505 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,URIBL_BLOCKED,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 ED543C433E0 for ; Wed, 20 Jan 2021 07:27:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 65D4023131 for ; Wed, 20 Jan 2021 07:27:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65D4023131 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7F4176B0005; Wed, 20 Jan 2021 02:27:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 77C506B0006; Wed, 20 Jan 2021 02:27:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61EBD6B0007; Wed, 20 Jan 2021 02:27:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id 48CBE6B0005 for ; Wed, 20 Jan 2021 02:27:35 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 06A531EE6 for ; Wed, 20 Jan 2021 07:27:35 +0000 (UTC) X-FDA: 77725323270.06.fruit95_2907d7627558 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id CF0E310040CB1 for ; Wed, 20 Jan 2021 07:27:34 +0000 (UTC) X-HE-Tag: fruit95_2907d7627558 X-Filterd-Recvd-Size: 2887 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Jan 2021 07:27:33 +0000 (UTC) IronPort-SDR: XFehmOi6DJGiw/RCCocA1UdESAbMi1VX0NvM+khtaDzGh6VqfG/uN8VFgPEehJLR70Kg/hR579 DC2K+sr+K58w== X-IronPort-AV: E=McAfee;i="6000,8403,9869"; a="158833869" X-IronPort-AV: E=Sophos;i="5.79,360,1602572400"; d="scan'208";a="158833869" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2021 23:27:32 -0800 IronPort-SDR: jehrqGgljQOaCPdMz3iBg9FeTtt/OjUDpnGO95N50pRIPyArG6CYEe0MUdfNpxV6smC/2dsfdM 9kY9OfW0exXw== X-IronPort-AV: E=Sophos;i="5.79,360,1602572400"; d="scan'208";a="355947381" Received: from yhuang6-mobl1.sh.intel.com ([10.238.6.89]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2021 23:27:22 -0800 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Minchan Kim , Joonsoo Kim , Johannes Weiner , Vlastimil Babka , Mel Gorman , Michal Hocko , Dan Williams , Christoph Hellwig Subject: [PATCH] swap: Check nrexceptional of swap cache before being freed Date: Wed, 20 Jan 2021 15:27:11 +0800 Message-Id: <20210120072711.209099-1-ying.huang@intel.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To catch the error in updating the swap cache shadow entries or their count. Signed-off-by: "Huang, Ying" Cc: Minchan Kim Cc: Joonsoo Kim , Cc: Johannes Weiner , Cc: Vlastimil Babka , Hugh Dickins , Cc: Mel Gorman , Cc: Michal Hocko , Cc: Dan Williams , Cc: Christoph Hellwig , Ilya Dryomov , --- mm/swap_state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index d0d417efeecc..240a4f97594a 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -703,7 +703,12 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages) void exit_swap_address_space(unsigned int type) { - kvfree(swapper_spaces[type]); + int i; + struct address_space *spaces = swapper_spaces[type]; + + for (i = 0; i < nr_swapper_spaces[type]; i++) + VM_BUG_ON(spaces[i].nrexceptional); + kvfree(spaces); nr_swapper_spaces[type] = 0; swapper_spaces[type] = NULL; }