Commit 1f618d52 authored by Simon Glass's avatar Simon Glass
Browse files

bloblist: Correct condition in bloblist_addrec()

It is possible to add a blob that ends at the end of the bloblist, but at
present this is not supported. Fix it and add a regression test for this
Signed-off-by: Simon Glass's avatarSimon Glass <>
parent faff5542
......@@ -118,7 +118,7 @@ static int bloblist_addrec(uint tag, int size, int align,
/* Calculate the new allocated total */
new_alloced = data_start + ALIGN(size, align);
if (new_alloced >= hdr->size) {
if (new_alloced > hdr->size) {
"Failed to allocate %x bytes size=%x, need size=%x\n",
size, hdr->size, new_alloced);
......@@ -576,6 +576,29 @@ static int bloblist_test_resize_last(struct unit_test_state *uts)
BLOBLIST_TEST(bloblist_test_resize_last, 0);
/* Check a completely full bloblist */
static int bloblist_test_blob_maxsize(struct unit_test_state *uts)
void *ptr;
int size;
/* At the start there should be no records */
ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
/* Add a blob that takes up all space */
size = TEST_BLOBLIST_SIZE - sizeof(struct bloblist_hdr) -
sizeof(struct bloblist_rec);
ptr = bloblist_add(TEST_TAG, size, 0);
ptr = bloblist_add(TEST_TAG, size + 1, 0);
return 0;
BLOBLIST_TEST(bloblist_test_blob_maxsize, 0);
int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment