efi_loader: capsule: fix SIZEOF_MISMATCH warning
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Fri, 22 Jan 2021 01:43:27 +0000 (10:43 +0900)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 23 Jan 2021 06:56:53 +0000 (07:56 +0100)
CID 316361 says:
> Passing argument "count * 8UL /* sizeof (*files) */" to
> function "dlmalloc" and then casting the return value to "u16 **" is
> suspicious. In this particular case "sizeof (u16 **)" happens to be equal
> to "sizeof (u16 *)", but this is not a portable assumption.
> > 767         tmp_files = malloc(count * sizeof(*files));

The change in this patch fixes the ambiguity.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Fixes: CID 316361
For readability use *tmp_files instead of tmp_files[0]
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_capsule.c

index dad1b0f..0d5a7b6 100644 (file)
@@ -764,7 +764,7 @@ static efi_status_t efi_capsule_scan_dir(u16 ***files, unsigned int *num)
                goto err;
 
        /* make a list */
-       tmp_files = malloc(count * sizeof(*files));
+       tmp_files = malloc(count * sizeof(*tmp_files));
        if (!tmp_files) {
                ret = EFI_OUT_OF_RESOURCES;
                goto err;