From patchwork Tue Jun 3 04:04:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 355157 X-Patchwork-Delegate: trini@ti.com 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 D652E14008F for ; Tue, 3 Jun 2014 14:06:54 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2F1964B8D9; Tue, 3 Jun 2014 06:06:42 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 jX9hYkYcy2Yn; Tue, 3 Jun 2014 06:06:41 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 532064B8DB; Tue, 3 Jun 2014 06:05:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BF0454B8B8 for ; Tue, 3 Jun 2014 06:05:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 U+ivOVTckF3y for ; Tue, 3 Jun 2014 06:05:30 +0200 (CEST) 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-pa0-f73.google.com (mail-pa0-f73.google.com [209.85.220.73]) by theia.denx.de (Postfix) with ESMTPS id 7B1904B89D for ; Tue, 3 Jun 2014 06:05:09 +0200 (CEST) Received: by mail-pa0-f73.google.com with SMTP id lj1so577538pab.2 for ; Mon, 02 Jun 2014 21:05:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8CIg+nDSEe28WFZdcHKcE54+9rp8/k38k4jlKagwjBA=; b=bL1ndMCYQKvgca9w3rZKLW5xHLULaMek8UEI/qkpjpdWweNCm9DXm75L4Yay0aCO97 HRN2mUWEIFMx7NwmGJu7Qyzk1zHowO+gPhDWpjz1kq2ElByPrvb4E8V52L4I6Hr+KKTd kZ7yCWwBU3yOZcCr0lTG0vm/titCQAeM0Ub/ijy4zbvxjzXR/G8yjXu/M9kpvY31MioM 1k6DwK/ZSMzNfR1E+E/6E7Ll3j9tjDZwhq6QaAWUs1pD1oWq5D0hujxXpce6/udtg8eQ Zu6NKJVQ7btbPUz5j4A86V18AxzaVCoy6ka/o8MIpmyom3WYz0VgBRyOvp4UzfRqXQ1D wpAQ== X-Gm-Message-State: ALoCoQmFVADLyaqVZ++I1tRVJi0BE1EkGigTU+VD+WhRiJFS9ic9wrkOsFKOTb5ZxCcrY1wAUgmD X-Received: by 10.68.133.138 with SMTP id pc10mr14928564pbb.5.1401768307717; Mon, 02 Jun 2014 21:05:07 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id c50si974634yhl.7.2014.06.02.21.05.07 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jun 2014 21:05:07 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 75CA031C42C; Mon, 2 Jun 2014 21:05:07 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 4231B220C55; Mon, 2 Jun 2014 22:05:07 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 2 Jun 2014 22:04:51 -0600 Message-Id: <1401768297-7198-9-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1401768297-7198-1-git-send-email-sjg@chromium.org> References: <1401768297-7198-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Jerry Van Baren Subject: [U-Boot] [PATCH v3 08/14] fdt: Update functions which write to an FDT to return -ENOSPC X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de When writing values into an FDT it is possible that there will be insufficient space. If the caller gets a useful error then it can potentially deal with the situation. Adjust these functions to return -ENOSPC when the FDT is full. Signed-off-by: Simon Glass --- Changes in v3: - Fix typo in commit message Changes in v2: - Fix line over 80cols common/image-fit.c | 4 ++-- include/rsa.h | 3 ++- lib/rsa/rsa-sign.c | 28 +++++++++++++++++++--------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/common/image-fit.c b/common/image-fit.c index 77f32bc..732505a 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -833,7 +833,7 @@ static int fit_image_hash_get_ignore(const void *fit, int noffset, int *ignore) * * returns: * 0, on success - * -1, on property read failure + * -ENOSPC if no space in device tree, -1 for other error */ int fit_set_timestamp(void *fit, int noffset, time_t timestamp) { @@ -847,7 +847,7 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp) printf("Can't set '%s' property for '%s' node (%s)\n", FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset, NULL), fdt_strerror(ret)); - return -1; + return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -1; } return 0; diff --git a/include/rsa.h b/include/rsa.h index a5680ab..325751a 100644 --- a/include/rsa.h +++ b/include/rsa.h @@ -60,7 +60,8 @@ int rsa_sign(struct image_sign_info *info, * * @info: Specifies key and FIT information * @keydest: Destination FDT blob for public key data - * @return: 0, on success, -ve on error + * @return: 0, on success, -ENOSPC if the keydest FDT blob ran out of space, + other -ve value on error */ int rsa_add_verify_data(struct image_sign_info *info, void *keydest); #else diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index ca8c120..48f3197 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -429,20 +429,30 @@ int rsa_add_verify_data(struct image_sign_info *info, void *keydest) ret = fdt_setprop_string(keydest, node, "key-name-hint", info->keyname); - ret |= fdt_setprop_u32(keydest, node, "rsa,num-bits", bits); - ret |= fdt_setprop_u32(keydest, node, "rsa,n0-inverse", n0_inv); - ret |= fdt_add_bignum(keydest, node, "rsa,modulus", modulus, bits); - ret |= fdt_add_bignum(keydest, node, "rsa,r-squared", r_squared, bits); - ret |= fdt_setprop_string(keydest, node, FIT_ALGO_PROP, - info->algo->name); + if (!ret) + ret = fdt_setprop_u32(keydest, node, "rsa,num-bits", bits); + if (!ret) + ret = fdt_setprop_u32(keydest, node, "rsa,n0-inverse", n0_inv); + if (!ret) { + ret = fdt_add_bignum(keydest, node, "rsa,modulus", modulus, + bits); + } + if (!ret) { + ret = fdt_add_bignum(keydest, node, "rsa,r-squared", r_squared, + bits); + } + if (!ret) { + ret = fdt_setprop_string(keydest, node, FIT_ALGO_PROP, + info->algo->name); + } if (info->require_keys) { - fdt_setprop_string(keydest, node, "required", - info->require_keys); + ret = fdt_setprop_string(keydest, node, "required", + info->require_keys); } BN_free(modulus); BN_free(r_squared); if (ret) - return -EIO; + return ret == FDT_ERR_NOSPACE ? -ENOSPC : -EIO; return 0; }