From 9c4d85d83af20b7e83ebcb577cd3566619abd545 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 2 Apr 2024 08:00:14 +0000 Subject: lib: Refactor bmp_load_logo() implementation This refactoring ensures bmp_load_logo() takes logo_size as an argument, returning a valid logo_ptr only if logo_size is non-zero. This prevents potential errors from mismatched size assumption. BUG=b:242829490 TEST=google/rex0 builds successfully. Change-Id: I14bc54670a67980ec93bc366b274832d1f959e50 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/81618 Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) Reviewed-by: Dinesh Gehlot Reviewed-by: Julius Werner --- src/drivers/intel/fsp2_0/fsp_gop_blt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/drivers/intel/fsp2_0') diff --git a/src/drivers/intel/fsp2_0/fsp_gop_blt.c b/src/drivers/intel/fsp2_0/fsp_gop_blt.c index 8b64502224..f59bb86b76 100644 --- a/src/drivers/intel/fsp2_0/fsp_gop_blt.c +++ b/src/drivers/intel/fsp2_0/fsp_gop_blt.c @@ -237,13 +237,15 @@ void fsp_convert_bmp_to_gop_blt(uint32_t *logo, uint32_t *logo_size, uint32_t *blt_ptr, uint32_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width) { - uint32_t logo_ptr, logo_ptr_size, blt_buffer_size; + uint32_t logo_ptr; + size_t logo_ptr_size, blt_buffer_size; efi_bmp_image_header *bmp_header; if (!logo || !logo_size || !blt_ptr || !blt_size || !pixel_height || !pixel_width) return; - bmp_load_logo(&logo_ptr, &logo_ptr_size); + logo_ptr = (uint32_t)(uintptr_t)bmp_load_logo(&logo_ptr_size); + if (!logo_ptr || logo_ptr_size < sizeof(efi_bmp_image_header)) { printk(BIOS_ERR, "%s: BMP Image size is too small.\n", __func__); return; -- cgit v1.2.3