[v2,19/35] video: stm32: lvds: fix NULL pointer dereference on missing data-mapping

Message ID 20261107143241.2236511-20-dario.binacchi@amarulasolutions.com
State New
Headers
Series Add Engicam MicroGEA-STM32MP257D-RMM board support |

Commit Message

Dario Binacchi Nov. 7, 2026, 2:32 p.m. UTC
The "data-mapping" property is only required by the panel-lvds binding,
so ofnode_read_string() may return NULL. Avoid a NULL pointer
dereference in this case by falling back to the VESA mapping, as for any
value other than "jeida-24".

Fixes: 16cfbbbe2b51 ("video: stm32: STM32 driver support for LVDS")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

(no changes since v1)

 drivers/video/stm32/stm32_lvds.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

-- 
2.43.0
  

Comments

Patrice CHOTARD Nov. 16, 2026, 10:12 a.m. UTC | #1
On 11/7/26 15:32, Dario Binacchi wrote:
> The "data-mapping" property is only required by the panel-lvds binding,
> so ofnode_read_string() may return NULL. Avoid a NULL pointer
> dereference in this case by falling back to the VESA mapping, as for any
> value other than "jeida-24".
> 
> Fixes: 16cfbbbe2b51 ("video: stm32: STM32 driver support for LVDS")
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> ---
> 
> (no changes since v1)
> 
>  drivers/video/stm32/stm32_lvds.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/video/stm32/stm32_lvds.c b/drivers/video/stm32/stm32_lvds.c
> index bf1393c9e872..a16331296388 100644
> --- a/drivers/video/stm32/stm32_lvds.c
> +++ b/drivers/video/stm32/stm32_lvds.c
> @@ -614,9 +614,7 @@ static int stm32_lvds_of_to_plat(struct udevice *dev)
>  	}
>  
>  	data_mapping = ofnode_read_string(dev_ofnode(plat->panel), "data-mapping");
> -	if (!strcmp(data_mapping, "vesa-24"))
> -		priv->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
> -	else if (!strcmp(data_mapping, "jeida-24"))
> +	if (data_mapping && !strcmp(data_mapping, "jeida-24"))
>  		priv->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
>  	else
>  		priv->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
Hi Dario

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
  
Raphael Gallais-Pou Nov. 16, 2026, 2:57 p.m. UTC | #2
On 11/7/26 15:32, Dario Binacchi wrote:
> The "data-mapping" property is only required by the panel-lvds binding,
> so ofnode_read_string() may return NULL. Avoid a NULL pointer
> dereference in this case by falling back to the VESA mapping, as for any
> value other than "jeida-24".
>
> Fixes: 16cfbbbe2b51 ("video: stm32: STM32 driver support for LVDS")
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> ---
>
>

Hi Dario, 

Reviewed-by: Raphaël Gallais-Pou <raphael.gallais-pou@foss.st.com>

Thanks,
Best regards,
Raphaël
  
Patrice CHOTARD Nov. 26, 2026, 7:46 a.m. UTC | #3
On 11/16/26 15:57, Raphael Gallais-Pou wrote:
> 
> 
> On 11/7/26 15:32, Dario Binacchi wrote:
>> The "data-mapping" property is only required by the panel-lvds binding,
>> so ofnode_read_string() may return NULL. Avoid a NULL pointer
>> dereference in this case by falling back to the VESA mapping, as for any
>> value other than "jeida-24".
>>
>> Fixes: 16cfbbbe2b51 ("video: stm32: STM32 driver support for LVDS")
>> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>> ---
>>
>>
> 
> Hi Dario, 
> 
> Reviewed-by: Raphaël Gallais-Pou <raphael.gallais-pou@foss.st.com>
> 
> Thanks,
> Best regards,
> Raphaël
Applied to u-boot-stm32/main

Thanks
Patrice
  

Patch

diff --git a/drivers/video/stm32/stm32_lvds.c b/drivers/video/stm32/stm32_lvds.c
index bf1393c9e872..a16331296388 100644
--- a/drivers/video/stm32/stm32_lvds.c
+++ b/drivers/video/stm32/stm32_lvds.c
@@ -614,9 +614,7 @@  static int stm32_lvds_of_to_plat(struct udevice *dev)
 	}
 
 	data_mapping = ofnode_read_string(dev_ofnode(plat->panel), "data-mapping");
-	if (!strcmp(data_mapping, "vesa-24"))
-		priv->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
-	else if (!strcmp(data_mapping, "jeida-24"))
+	if (data_mapping && !strcmp(data_mapping, "jeida-24"))
 		priv->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
 	else
 		priv->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;