Received: by 10.223.148.5 with SMTP id 5csp6591639wrq; Wed, 17 Jan 2018 16:08:09 -0800 (PST) X-Google-Smtp-Source: ACJfBotBG9ThBuNONnOcpZ7XFgEhl6Ew3HwkL6Q/rUaKfIgS1NPEr6kC91wzr+kpjVJnFHYEYA+s X-Received: by 10.101.70.199 with SMTP id n7mr12749074pgr.303.1516234089404; Wed, 17 Jan 2018 16:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516234089; cv=none; d=google.com; s=arc-20160816; b=AOKFE8rkQUMPR/MulLOKGyJfeXDdvr6fBusB0jRThRrUmfDuqopAOmNVgpVO86/x3K D5tz+qGt5L7+8CaZ6dv5qhMoryRYfnGAXvLuc7qJiOxvN1XauxmRFy2EISWtXsEo/7Vm v8YCAWswgqGtGPmFrOZOauTiKF9Z2uF8SewLod4YvdoZwoglV9eW0wNHHNTdiBrIyRSb uP3xnhrZNffBNrNCf/af0gbFOJGtZ1D+s6gUHC+JwNGvQRcgh0JwEnOz5FvmZKjl6SkE qEDkOJk4sRw46cGdJ5y+Pq3i6y+E3y2Oq5l5whBPHAc+oE0iWIDSmyV6s5MhkCeUb2aM iONA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=auek5W+ei42nmqfiOY8BPlF1lUOY3BWG1OTx0UWZqmc=; b=QD+mRpUSKhr59UTvIkV2jTs/YL6zQThjBle3E7su/ERMxPnYfmnB9udnEBd140mB1o vLiCOBOlsGGeRX//v8SLdTTfHGCYz8rq+Yfgchohxc95gKu12B0vEZ227QnjNdaAqWGG FHckypLfqzAkaKBIhJnnuP8Ylqrsr8YPuTxU9mJtdGkOwVgvN8Ner7MGe0tGTKBSFiJH WzEDRbnRiIx6/z4eoAilHQCFq7DzeGtKNEGjvlRBDtF8Tbf/OH8xusYRyrFlFZbPEetq eK7jyaY5mC67oEBhERgtJweGDf7wVNmxEACC4bZ6YApiUMNdGKYDJJTGoel58AKgn0IM Xwaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=D+WTxR2O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x25si4794900pgc.643.2018.01.17.16.07.54; Wed, 17 Jan 2018 16:08:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=D+WTxR2O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754660AbeARAHP (ORCPT + 99 others); Wed, 17 Jan 2018 19:07:15 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:51118 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752062AbeARAHN (ORCPT ); Wed, 17 Jan 2018 19:07:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1516234033; x=1547770033; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=auek5W+ei42nmqfiOY8BPlF1lUOY3BWG1OTx0UWZqmc=; b=D+WTxR2Our9SC64auKBgIsKSJ4FpLl2VGobZTQM/XWSDf2PBgcm95Dyy q+XGbzch1Y9WKBRnNi275fE6U9tlhK8qcm5rYB0uqVKDFN6p45ygAOXl2 Lf6PsgWrzzOrDD92s8X/c8ldYdg4u9pbA5lNOd0VedvjQJNHP6cJuJsNP E=; X-IronPort-AV: E=Sophos;i="5.46,374,1511827200"; d="scan'208";a="327771627" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 18 Jan 2018 00:07:04 +0000 Received: from u7588a65da6b65f.ant.amazon.com (iad1-ws-svc-lb91-vlan2.amazon.com [10.0.103.146]) by email-inbound-relay-1d-f273de60.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w0I06xT8046188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 18 Jan 2018 00:07:01 GMT Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id w0I06vc4005650 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Jan 2018 01:06:57 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id w0I06uIJ005646; Thu, 18 Jan 2018 01:06:56 +0100 From: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= To: Andrew Morton , Dan Williams Cc: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm: Fix memory size alignment in devm_memremap_pages_release() Date: Thu, 18 Jan 2018 01:06:01 +0100 Message-Id: <20180118000602.5527-1-jschoenh@amazon.de> X-Mailer: git-send-email 2.9.3.1.gcba166c.dirty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The functions devm_memremap_pages() and devm_memremap_pages_release() use different ways to calculate the section-aligned amount of memory. The latter function may use an incorrect size if the memory region is small but straddles a section border. Use the same code for both. Fixes: 5f29a77cd957 ("mm: fix mixed zone detection in devm_memremap_pages") Signed-off-by: Jan H. Schönherr --- kernel/memremap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/memremap.c b/kernel/memremap.c index 403ab9c..4712ce6 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -301,7 +301,8 @@ static void devm_memremap_pages_release(struct device *dev, void *data) /* pages are dead and unused, undo the arch mapping */ align_start = res->start & ~(SECTION_SIZE - 1); - align_size = ALIGN(resource_size(res), SECTION_SIZE); + align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) + - align_start; mem_hotplug_begin(); arch_remove_memory(align_start, align_size); -- 2.9.3.1.gcba166c.dirty