Fix file_to_uuid() function
authorSandrine Bailleux <sandrine.bailleux@arm.com>
Wed, 19 Mar 2014 16:03:48 +0000 (16:03 +0000)
committerDan Handley <dan.handley@arm.com>
Fri, 21 Mar 2014 17:17:48 +0000 (17:17 +0000)
This patch fixes a bug in the 'file_to_uuid()' function: it used
to cause an exception by dereferencing a null pointer when
a given UUID was not found in the UUID array. The fix is to delete
the final null entry in the UUID array, which is not needed because
the array is statically declared so its size is known at build time.

Fixes ARM-software/tf-issues#43

Change-Id: I0a003485b88134564c0d36f57c274215d9e16532

drivers/io/io_fip.c

index 372537218d9498ff8fc83a8ebfd153eaf4a4a13d..1eb76faaa5c88f0d21eca6c71af9726e610990ff 100644 (file)
@@ -67,7 +67,6 @@ static plat_fip_name_uuid name_uuid[] = {
        {BL31_IMAGE_NAME, UUID_EL3_RUNTIME_FIRMWARE_BL31},
        {BL32_IMAGE_NAME, UUID_SECURE_PAYLOAD_BL32},
        {BL33_IMAGE_NAME, UUID_NON_TRUSTED_FIRMWARE_BL33},
-       {NULL, {0} }
 };
 
 static const uuid_t uuid_null = {0};
@@ -118,7 +117,7 @@ static int file_to_uuid(const char *filename, uuid_t *uuid)
        int i;
        int status = -EINVAL;
 
-       for (i = 0; i < (sizeof(name_uuid)/sizeof(plat_fip_name_uuid)); i++) {
+       for (i = 0; i < (sizeof(name_uuid) / sizeof(name_uuid[0])); i++) {
                if (strcmp(filename, name_uuid[i].name) == 0) {
                        copy_uuid(uuid, &name_uuid[i].uuid);
                        status = 0;