From patchwork Fri Sep 24 22:44:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12516981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CD07C433F5 for ; Fri, 24 Sep 2021 22:44:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFFF3610F7 for ; Fri, 24 Sep 2021 22:44:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DFFF3610F7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 839536B0071; Fri, 24 Sep 2021 18:44:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EA036B0088; Fri, 24 Sep 2021 18:44:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FF26900002; Fri, 24 Sep 2021 18:44:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 61B666B0071 for ; Fri, 24 Sep 2021 18:44:05 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 17E1039B1D for ; Fri, 24 Sep 2021 22:44:05 +0000 (UTC) X-FDA: 78623946450.06.E69D8DF Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf28.hostedemail.com (Postfix) with ESMTP id C7A87900009E for ; Fri, 24 Sep 2021 22:44:04 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id B8D9161250; Fri, 24 Sep 2021 22:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1632523444; bh=V8C691MMOp/rWW4+HTIKqi0ephg0nY4mpRWWs4qB8yU=; h=Date:From:To:Subject:In-Reply-To:From; b=t0pPPTwOGRfVJfY9ZeLSWafgvszfjIcAFXKPmMCCzkWppoQG2y4UQpT6I5B9SDHMy 6PG+IViX3Q5SWW/lgsS5pLzqwW1y/zxJTGYSW5IHNVo//1rHt04VObA3uQOHS9pEWk N73QTqP4J98M/Mh1JzxArVlJWKllh7H+VEy5SNMI= Date: Fri, 24 Sep 2021 15:44:03 -0700 From: Andrew Morton To: akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, naoya.horiguchi@nec.com, songmuchun@bytedance.com, torvalds@linux-foundation.org, zhengqi.arch@bytedance.com Subject: [patch 15/16] mm/memory_failure: fix the missing pte_unmap() call Message-ID: <20210924224403.3ZN1b5z2V%akpm@linux-foundation.org> In-Reply-To: <20210924154257.1dbf6699ab8d88c0460f924f@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C7A87900009E X-Stat-Signature: 9ji6snxtz73zuz8g33q8s4hktkz6onu5 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=t0pPPTwO; dmarc=none; spf=pass (imf28.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1632523444-741393 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: From: Qi Zheng Subject: mm/memory_failure: fix the missing pte_unmap() call The paired pte_unmap() call is missing before the dev_pagemap_mapping_shift() returns. So fix it. Davidsaid "I guess this code never runs on 32bit / highmem, that's why we didn't notice so far". [akpm@linux-foundation.org: cleanup] Link: https://lkml.kernel.org/r/20210923122642.4999-1-zhengqi.arch@bytedance.com Signed-off-by: Qi Zheng Reviewed-by: David Hildenbrand Cc: Naoya Horiguchi Cc: Muchun Song Signed-off-by: Andrew Morton --- mm/memory-failure.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/mm/memory-failure.c~mm-memory_failure-fix-the-missing-pte_unmap-call +++ a/mm/memory-failure.c @@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping struct vm_area_struct *vma) { unsigned long address = vma_address(page, vma); + unsigned long ret = 0; pgd_t *pgd; p4d_t *p4d; pud_t *pud; @@ -329,11 +330,10 @@ static unsigned long dev_pagemap_mapping if (pmd_devmap(*pmd)) return PMD_SHIFT; pte = pte_offset_map(pmd, address); - if (!pte_present(*pte)) - return 0; - if (pte_devmap(*pte)) - return PAGE_SHIFT; - return 0; + if (pte_present(*pte) && pte_devmap(*pte)) + ret = PAGE_SHIFT; + pte_unmap(pte); + return ret; } /*