From: Tvrtko Ursulin Date: Mon, 8 Dec 2025 19:39:23 +0000 (+0100) Subject: efi: sysfb_efi: Fix lfb_linelength calculation when applying quirks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=449b87e81f3561bd907d3b9a31cf69590132a2df;p=thirdparty%2Flinux.git efi: sysfb_efi: Fix lfb_linelength calculation when applying quirks PIXEL_BIT_MASK formats can have either less or more than four bytes per pixel so lets fix the lfb_linelenght calculation when applying the swapped width and height quirks. Signed-off-by: Tvrtko Ursulin Suggested-by: Thomas Zimmermann Cc: Thomas Zimmermann Cc: Ard Biesheuvel Cc: Melissa Wen Cc: linux-efi@vger.kernel.org Tested-by: Melissa Wen # v3 Reviewed-by: Thomas Zimmermann Signed-off-by: Ard Biesheuvel --- diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c index 1d8b6966731c3..60495eb3441c3 100644 --- a/drivers/firmware/efi/sysfb_efi.c +++ b/drivers/firmware/efi/sysfb_efi.c @@ -357,8 +357,11 @@ __init void sysfb_apply_efi_quirks(void) if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI && dmi_check_system(efifb_dmi_swap_width_height)) { + u32 bpp = __screen_info_lfb_bits_per_pixel(&screen_info); + swap(screen_info.lfb_width, screen_info.lfb_height); - screen_info.lfb_linelength = 4 * screen_info.lfb_width; + screen_info.lfb_linelength = bpp * screen_info.lfb_width / + BITS_PER_BYTE; } }