drm/efidrm: ensure screen_base is initialized
Subsystems (3)
PATCH 1/1 drm/efidrm: ensure screen_base is initialized
From: Arnd Bergmann <[email protected]>
clang points out that there is a code path that leads to undefined behavior:
drivers/gpu/drm/sysfb/efidrm.c:353:11: error: variable 'screen_base' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
353 | else if (mem_flags & EFI_MEMORY_WB)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
Add the missing initialization.
--- drivers/gpu/drm/sysfb/efidrm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/sysfb/efidrm.c +3 -0
@@ -353,6 +353,9 @@ static struct efidrm_device *efidrm_device_create(struct drm_driver *drv,else if (mem_flags &EFI_MEMORY_WB ) screen_base =devm_memremap (&pdev->dev, mem->start,resource_size (mem),MEMREMAP_WB ); +else + screen_base =NULL ; +if (!screen_base)return ERR_PTR (-ENOMEM );iosys_map_set_vaddr_iomem (&sysfb->fb_addr, screen_base);
Signature · 1 line
2.39.5
Javier Martinez Canillas
maintainerArnd Bergmann <[email protected]> writes:
Hello Arnd,
Quoted 6 lines
From: Arnd Bergmann <[email protected]>
clang points out that there is a code path that leads to undefined behavior:
drivers/gpu/drm/sysfb/efidrm.c:353:11: error: variable 'screen_base' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
353 | else if (mem_flags&EFI_MEMORY_WB)
Quoted 7 lines
| ^~~~~~~~~~~~~~~~~~~~~~~~~Add the missing initialization.
Fixes 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays")Signed-off-by Arnd Bergmann <[email protected]>---
A similar patch has been proposed by Nathan already and acked by Thomas:
https://lists.freedesktop.org/archives/dri-devel/2025-April/500539.html
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerHi Arnd
Am 11.04.25 um 15:11 schrieb Javier Martinez Canillas:
Quoted 5 lines
Arnd Bergmann <[email protected]> writes:
Hello Arnd,
Quoted 1 line
From: Arnd Bergmann <[email protected]>
Thanks for the fix.
Quoted 7 lines
Quoted 7 lines
clang points out that there is a code path that leads to undefined behavior:
drivers/gpu/drm/sysfb/efidrm.c:353:11: error: variable 'screen_base' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
353 | else if (mem_flags&EFI_MEMORY_WB)| ^~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines
Quoted 5 lines
Add the missing initialization.
Fixes 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays")Signed-off-by Arnd Bergmann <[email protected]>---
A similar patch has been proposed by Nathan already and acked by Thomas:
https://lists.freedesktop.org/archives/dri-devel/2025-April/500539.html
I've meanwhile merged this patch into drm-misc-next.
Best regards
Thomas
Quoted 1 line
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)