From patchwork Wed Aug 3 15:35:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Iles X-Patchwork-Id: 1031842 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p73FZm5E007693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 3 Aug 2011 15:36:09 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QodTw-0000vY-5D; Wed, 03 Aug 2011 15:35:40 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QodTv-0003Ra-NR; Wed, 03 Aug 2011 15:35:39 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QodTr-0003RI-Di for linux-arm-kernel@lists.infradead.org; Wed, 03 Aug 2011 15:35:37 +0000 Received: by wyg19 with SMTP id 19so357538wyg.36 for ; Wed, 03 Aug 2011 08:35:32 -0700 (PDT) Received: by 10.227.205.78 with SMTP id fp14mr8372140wbb.65.1312385732577; Wed, 03 Aug 2011 08:35:32 -0700 (PDT) Received: from localhost (gw-ba1.picochip.com [94.175.234.108]) by mx.google.com with ESMTPS id em16sm767841wbb.50.2011.08.03.08.35.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Aug 2011 08:35:32 -0700 (PDT) From: Jamie Iles To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] mm: fix invalid loop for poison_init_mem Date: Wed, 3 Aug 2011 16:35:28 +0100 Message-Id: <1312385728-27311-1-git-send-email-jamie@jamieiles.com> X-Mailer: git-send-email 1.7.4.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110803_113535_597553_6C670382 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] Cc: Nicolas Pitre , Jamie Iles , Stephen Boyd , Russell King X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 03 Aug 2011 15:36:09 +0000 (UTC) poison_init_mem() used a loop of: while ((count = count - 4)) which has 2 problems - an off by one error so that we do one less word than we should, and the other is that if count == 0 then we loop forever and poison too much. On a platform with HAVE_TCM=y but nothing in the TCM's, this caused corruption and the platform failed to boot. Cc: Stephen Boyd Cc: Nicolas Pitre Cc: Russell King Signed-off-by: Jamie Iles Acked-by: Nicolas Pitre Acked-by: Stephen Boyd --- arch/arm/mm/init.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 2fee782..91bca35 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -441,7 +441,7 @@ static inline int free_area(unsigned long pfn, unsigned long end, char *s) static inline void poison_init_mem(void *s, size_t count) { u32 *p = (u32 *)s; - while ((count = count - 4)) + for (; count != 0; count -= 4) *p++ = 0xe7fddef0; }