From patchwork Mon Aug 13 07:33:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 956867 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DGW70RTw"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41png80Cfpz9s9l for ; Mon, 13 Aug 2018 17:39:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 242E9C21E62; Mon, 13 Aug 2018 07:36:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 594B0C21DFF; Mon, 13 Aug 2018 07:35:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0E8F8C21DFA; Mon, 13 Aug 2018 07:34:27 +0000 (UTC) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by lists.denx.de (Postfix) with ESMTPS id ADE50C21E1D for ; Mon, 13 Aug 2018 07:34:23 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id c13-v6so13376984wrt.1 for ; Mon, 13 Aug 2018 00:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k5ANZvUyq56kJ5SJxgXJV5aY85L3g6Av3SuoEhkobGI=; b=DGW70RTwfpxCUb+cPCybSsGUb190ghja1KkxVVYDCwv7QeMWEFyBaXrk+KGCHiZgHo qGR+Ozfn6qBKHeEyOHe7KAb9VTTvwYhE3BiwD39hO09BPHYB0kukgT2K+aKNPXCbwqKI g5Ui8VTFa86mJBvFoztES5fiORYEIRL9xM862A9yn85hOQodVN9ltgrvu+B6mbNe07G2 6sYBr5z6fnrE3vO8l9UmCJQImjkqUTGV7ZNrPumvhxity+KtICeaYuZ9i3NS4qyzROyP 1yVqMMTozQ2gioWRTe3qtx3eZVF8Y2rvx2jshcM2G1n1oc7dbAafUsGM8kN9QL3Jdcpd PlOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k5ANZvUyq56kJ5SJxgXJV5aY85L3g6Av3SuoEhkobGI=; b=NmTBgacq7RqSUfMIC5Vt3pht6ino0jcc31zvD49qHg6yZDiMCnNpBkTc3OHhDrOLeH HF7UhFauzlwqa3kc9eQxGJ4KjTTQNbHjyAGa8W+tCd9u63P50bnoYG8bHg6J0+a+8mYx 2CT1HdC/Og+mMKkKTML+kaLBahbycu830z9mSVQj0PZUe7d0uHKjxLlp0Iobl2kcG/NJ QMr71lLq2b7g8YC99iiODpTWXYuZb6XT5TMLeJwlaKTkhqertnJQ7qXeSkCDrxUlppEm MLakCrWL9LB0JM9xpaNqnzJ8CNoBzBD+CR/cjD25eCkbgk5Gmft2PgqhhJqqKXH66N3s LLqA== X-Gm-Message-State: AOUpUlFNLI5qZfxM0kfqPnKa6U0Zxh04BF/T12N3eqfwDQiZmJmDKhuC Z0zvWd74oNRuB3t7ypAiX7s= X-Google-Smtp-Source: AA+uWPy85AlQKOlE62WUh8Sshu71A11puV7d7WPVAvxa2HiveXpnHo8FHnjATbQrSZV+HYEEMqzihA== X-Received: by 2002:adf:b642:: with SMTP id i2-v6mr9447732wre.54.1534145663488; Mon, 13 Aug 2018 00:34:23 -0700 (PDT) Received: from ubuntu.home ([2a02:8071:6a3:700:542c:ff11:9c97:a518]) by smtp.gmail.com with ESMTPSA id b8-v6sm19382806wrw.22.2018.08.13.00.34.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 00:34:22 -0700 (PDT) From: Simon Goldschmidt To: Marek Vasut Date: Mon, 13 Aug 2018 09:33:51 +0200 Message-Id: <20180813073351.29293-9-simon.k.r.goldschmidt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180813073351.29293-1-simon.k.r.goldschmidt@gmail.com> References: <20180813073351.29293-1-simon.k.r.goldschmidt@gmail.com> Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 8/8] malloc_simple: calloc: don't call memset if malloc failed X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" malloc_simple() can return 0 if out of memory. Don't call memset from calloc() in this case but rely on the caller checking the return value. Signed-off-by: Simon Goldschmidt Reviewed-by: Marek Vasut --- Changes in v3: None Changes in v2: None common/malloc_simple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/malloc_simple.c b/common/malloc_simple.c index c14f8b59c1..871b5444bd 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -57,7 +57,8 @@ void *calloc(size_t nmemb, size_t elem_size) void *ptr; ptr = malloc(size); - memset(ptr, '\0', size); + if (ptr) + memset(ptr, '\0', size); return ptr; }