From patchwork Tue Dec 29 12:22:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 561551 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 82B0A140BB5 for ; Tue, 29 Dec 2015 23:26:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=dA1zSnu0; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CAD5B4BA1B; Tue, 29 Dec 2015 13:25:41 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C2OU8UEKtroo; Tue, 29 Dec 2015 13:25:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 277E74B9EE; Tue, 29 Dec 2015 13:25:41 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 04CD24BA27 for ; Tue, 29 Dec 2015 13:24:36 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C-tUkafKN1c3 for ; Tue, 29 Dec 2015 13:24:35 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by theia.denx.de (Postfix) with ESMTPS id 1161F4B9CE for ; Tue, 29 Dec 2015 13:24:25 +0100 (CET) Received: by mail-ob0-f178.google.com with SMTP id ba1so158172365obb.3 for ; Tue, 29 Dec 2015 04:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=XJ4+qKewQYUu2wLF0bfE9q0IjtRWKA2aDK9jAFGTHnU=; b=dA1zSnu0lkx7e1KJimBJmeynRj1gkfIAXVekupoVaPHDpGOAZG9xRFKOdhktd3Kx3r eSWmYDCmstfUopMRWtEtMZcypoo/sgf9OsO5AYYGEgE579V+PWLwRU/r/ZI7v9GQJDnw b7exAyX6wrTAbGvHrmZtIv7pVRparonjp48LaPq9yj81YEz/ZzpW+z3Iw7wZqlgOoxhs DxF4MIsqYJZTKbN5jwVxphq1rI0FqtYpjfTQjjBynbp78H1+FjpcMysM/agdCeOPJPDe 185UUTMnGtbXZBfd+Li3IkNOQw4+PUgUVAelJFlCnLKS29X05UzOR0Xy6dNiL2EOBEur AShg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=XJ4+qKewQYUu2wLF0bfE9q0IjtRWKA2aDK9jAFGTHnU=; b=VzzWOjbL/I0ASO8wW1/k0QS/A8qSyqsFeXqroP6+F7qEc9yeWei7KCy4HuMBDvBYpg P90QuTDXnC++0P1z5UduB+j3Z+tU4pmxkJpaT4K5EpUSKJL8//aWsY6bBAusB9oehSYl hhHz08tGeoWMu7g3TqnxHSo2ZVVqFNibY79wl04s5R0+CNXiESrWoR5Lk1yipSFK31ax uVCupyCRmI06HvmKiP8H6qAHpnMEie2DX9Zv/tvwsFPcwSJ6LeBZ+On1m0B+hX+n56mJ al6O2twRmBfi+lfSYLcj/qY+FZ7AJ65lmBXy2v3VUH3lp+ZN8JwjA+fgc0F+TYPxX39F q01A== X-Gm-Message-State: ALoCoQn5pRV8ZcwpvzSc9zZR9m3GLJOILwLr1FtnO08iCyOsqoAViVjZqfj/B8fJ5YbzlYlG0etLCAzYxWPHgeD0dJV63Zfw/A== X-Received: by 10.60.17.1 with SMTP id k1mr35863509oed.4.1451391864285; Tue, 29 Dec 2015 04:24:24 -0800 (PST) Received: from kaki.bld.corp.google.com ([2620:0:1005:1100:ed25:a3b0:e50f:f915]) by smtp.gmail.com with ESMTPSA id u2sm6416887oej.4.2015.12.29.04.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Dec 2015 04:24:20 -0800 (PST) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 578852219A0; Tue, 29 Dec 2015 05:24:14 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Tue, 29 Dec 2015 05:22:51 -0700 Message-Id: <1451391772-6203-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1451391772-6203-1-git-send-email-sjg@chromium.org> References: <1451391772-6203-1-git-send-email-sjg@chromium.org> Cc: Joe Hershberger , Jeffy Chen Subject: [U-Boot] [PATCH 09/10] malloc_simple: Display an error when memory is exhausted X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This is an uncommon but annoying case. Normal error handling will ensure it is reported, but it is useful to have a message which provides a little more detail. Signed-off-by: Simon Glass --- common/malloc_simple.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/malloc_simple.c b/common/malloc_simple.c index 479a1e4..4621b6d 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -21,8 +21,11 @@ void *malloc_simple(size_t bytes) new_ptr = gd->malloc_ptr + bytes; debug("%s: size=%zx, ptr=%lx, limit=%lx\n", __func__, bytes, new_ptr, gd->malloc_limit); - if (new_ptr > gd->malloc_limit) + if (new_ptr > gd->malloc_limit) { + printf("Out of memory (%zu bytes, %lx requested)\n", bytes, + new_ptr); return NULL; + } ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes); gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));