mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-27 23:20:26 +09:00
fdt: Update functions which write to an FDT to return -ENOSPC
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 <sjg@chromium.org>
This commit is contained in:
parent
63b4b5bae5
commit
4f427a421f
@ -833,7 +833,7 @@ static int fit_image_hash_get_ignore(const void *fit, int noffset, int *ignore)
|
|||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* 0, on success
|
* 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)
|
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",
|
printf("Can't set '%s' property for '%s' node (%s)\n",
|
||||||
FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset, NULL),
|
FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset, NULL),
|
||||||
fdt_strerror(ret));
|
fdt_strerror(ret));
|
||||||
return -1;
|
return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -60,7 +60,8 @@ int rsa_sign(struct image_sign_info *info,
|
|||||||
*
|
*
|
||||||
* @info: Specifies key and FIT information
|
* @info: Specifies key and FIT information
|
||||||
* @keydest: Destination FDT blob for public key data
|
* @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);
|
int rsa_add_verify_data(struct image_sign_info *info, void *keydest);
|
||||||
#else
|
#else
|
||||||
|
@ -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",
|
ret = fdt_setprop_string(keydest, node, "key-name-hint",
|
||||||
info->keyname);
|
info->keyname);
|
||||||
ret |= fdt_setprop_u32(keydest, node, "rsa,num-bits", bits);
|
if (!ret)
|
||||||
ret |= fdt_setprop_u32(keydest, node, "rsa,n0-inverse", n0_inv);
|
ret = fdt_setprop_u32(keydest, node, "rsa,num-bits", bits);
|
||||||
ret |= fdt_add_bignum(keydest, node, "rsa,modulus", modulus, bits);
|
if (!ret)
|
||||||
ret |= fdt_add_bignum(keydest, node, "rsa,r-squared", r_squared, bits);
|
ret = fdt_setprop_u32(keydest, node, "rsa,n0-inverse", n0_inv);
|
||||||
ret |= fdt_setprop_string(keydest, node, FIT_ALGO_PROP,
|
if (!ret) {
|
||||||
info->algo->name);
|
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) {
|
if (info->require_keys) {
|
||||||
fdt_setprop_string(keydest, node, "required",
|
ret = fdt_setprop_string(keydest, node, "required",
|
||||||
info->require_keys);
|
info->require_keys);
|
||||||
}
|
}
|
||||||
BN_free(modulus);
|
BN_free(modulus);
|
||||||
BN_free(r_squared);
|
BN_free(r_squared);
|
||||||
if (ret)
|
if (ret)
|
||||||
return -EIO;
|
return ret == FDT_ERR_NOSPACE ? -ENOSPC : -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user