drivers/gpu/drm/sysfb/efidrm.c | 3 +++ 1 file changed, 3 insertions(+)
From: Arnd Bergmann <arnd@arndb.de>
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.
Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpu/drm/sysfb/efidrm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/sysfb/efidrm.c b/drivers/gpu/drm/sysfb/efidrm.c
index af90064a4c04..85fc37c1e87a 100644
--- a/drivers/gpu/drm/sysfb/efidrm.c
+++ b/drivers/gpu/drm/sysfb/efidrm.c
@@ -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);
--
2.39.5
Arnd Bergmann <arnd@kernel.org> writes:
Hello Arnd,
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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.
>
> Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
A similar patch has been proposed by Nathan already and acked by Thomas:
https://lists.freedesktop.org/archives/dri-devel/2025-April/500539.html
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
Hi Arnd
Am 11.04.25 um 15:11 schrieb Javier Martinez Canillas:
> Arnd Bergmann <arnd@kernel.org> writes:
>
> Hello Arnd,
>
>> From: Arnd Bergmann <arnd@arndb.de>
Thanks for the fix.
>>
>> 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.
>>
>> Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
> 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
>
--
--
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)
© 2016 - 2025 Red Hat, Inc.