#include <log.h>
#include <mapmem.h>
#include <spl.h>
+#include <u-boot/crc.h>
DECLARE_GLOBAL_DATA_PTR;
struct bloblist_rec *rec;
int new_alloced;
- new_alloced = hdr->alloced + sizeof(*rec) +
- ALIGN(size, BLOBLIST_ALIGN);
+ new_alloced = hdr->alloced + sizeof(*rec) + ALIGN(size, BLOBLIST_ALIGN);
if (new_alloced >= hdr->size) {
log(LOGC_BLOBLIST, LOGL_ERR,
- "Failed to allocate %x bytes size=%x, need size>=%x\n",
+ "Failed to allocate %x bytes size=%x, need size=%x\n",
size, hdr->size, new_alloced);
return log_msg_ret("bloblist add", -ENOSPC);
}
rec->hdr_size = sizeof(*rec);
rec->size = size;
rec->spare = 0;
+
+ /* Zero the record data */
+ memset(rec + 1, '\0', rec->size);
*recp = rec;
return 0;
rec = bloblist_findrec(tag);
if (rec) {
- if (size && size != rec->size)
+ if (size && size != rec->size) {
+ *recp = rec;
return -ESPIPE;
+ }
} else {
int ret;
return (void *)rec + rec->hdr_size;
}
+int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp)
+{
+ struct bloblist_rec *rec;
+ int ret;
+
+ ret = bloblist_ensurerec(tag, &rec, *sizep);
+ if (ret == -ESPIPE)
+ *sizep = rec->size;
+ else if (ret)
+ return ret;
+ *blobp = (void *)rec + rec->hdr_size;
+
+ return 0;
+}
+
static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr)
{
struct bloblist_rec *rec;