public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable
@ 2025-04-23 16:32 Arnd Bergmann
  2025-04-23 17:19 ` Dmitry Baryshkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnd Bergmann @ 2025-04-23 16:32 UTC (permalink / raw)
  To: Neil Armstrong, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	AngeloGioacchino Del Regno
  Cc: Arnd Bergmann, Jessica Zhang, dri-devel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

goa_even_valid is only initialized in one branch but not the other:

drivers/gpu/drm/panel/panel-himax-hx8279.c:838:6: error: variable 'goa_even_valid' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
  838 |         if (num_zero == ARRAY_SIZE(desc->goa_even_timing))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/panel/panel-himax-hx8279.c:842:23: note: uninitialized use occurs here
  842 |         if (goa_odd_valid != goa_even_valid)
      |                              ^~~~~~~~~~~~~~

Change the initialization to set it to the value of the condition instead.

Fixes: 38d42c261389 ("drm: panel: Add driver for Himax HX8279 DDIC panels")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/panel/panel-himax-hx8279.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-himax-hx8279.c b/drivers/gpu/drm/panel/panel-himax-hx8279.c
index b48b350b62da..4f548430654a 100644
--- a/drivers/gpu/drm/panel/panel-himax-hx8279.c
+++ b/drivers/gpu/drm/panel/panel-himax-hx8279.c
@@ -835,8 +835,7 @@ static int hx8279_check_goa_config(struct hx8279 *hx, struct device *dev)
 			num_zero++;
 	}
 
-	if (num_zero == ARRAY_SIZE(desc->goa_even_timing))
-		goa_even_valid = false;
+	goa_even_valid = (num_zero != ARRAY_SIZE(desc->goa_even_timing));
 
 	/* Programming one without the other would make no sense! */
 	if (goa_odd_valid != goa_even_valid)
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable
  2025-04-23 16:32 [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable Arnd Bergmann
@ 2025-04-23 17:19 ` Dmitry Baryshkov
  2025-04-24  7:21 ` AngeloGioacchino Del Regno
  2025-04-24  8:20 ` Neil Armstrong
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry Baryshkov @ 2025-04-23 17:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Neil Armstrong, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	AngeloGioacchino Del Regno, Arnd Bergmann, Jessica Zhang,
	dri-devel, linux-kernel

On Wed, Apr 23, 2025 at 06:32:07PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> goa_even_valid is only initialized in one branch but not the other:
> 
> drivers/gpu/drm/panel/panel-himax-hx8279.c:838:6: error: variable 'goa_even_valid' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>   838 |         if (num_zero == ARRAY_SIZE(desc->goa_even_timing))
>       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/panel/panel-himax-hx8279.c:842:23: note: uninitialized use occurs here
>   842 |         if (goa_odd_valid != goa_even_valid)
>       |                              ^~~~~~~~~~~~~~
> 
> Change the initialization to set it to the value of the condition instead.
> 
> Fixes: 38d42c261389 ("drm: panel: Add driver for Himax HX8279 DDIC panels")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/panel/panel-himax-hx8279.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable
  2025-04-23 16:32 [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable Arnd Bergmann
  2025-04-23 17:19 ` Dmitry Baryshkov
@ 2025-04-24  7:21 ` AngeloGioacchino Del Regno
  2025-04-24  8:20 ` Neil Armstrong
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-04-24  7:21 UTC (permalink / raw)
  To: Arnd Bergmann, Neil Armstrong, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Arnd Bergmann, Jessica Zhang, dri-devel, linux-kernel

Il 23/04/25 18:32, Arnd Bergmann ha scritto:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> goa_even_valid is only initialized in one branch but not the other:
> 
> drivers/gpu/drm/panel/panel-himax-hx8279.c:838:6: error: variable 'goa_even_valid' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>    838 |         if (num_zero == ARRAY_SIZE(desc->goa_even_timing))
>        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/panel/panel-himax-hx8279.c:842:23: note: uninitialized use occurs here
>    842 |         if (goa_odd_valid != goa_even_valid)
>        |                              ^~~~~~~~~~~~~~
> 
> Change the initialization to set it to the value of the condition instead.
> 
> Fixes: 38d42c261389 ("drm: panel: Add driver for Himax HX8279 DDIC panels")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

> ---
>   drivers/gpu/drm/panel/panel-himax-hx8279.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-himax-hx8279.c b/drivers/gpu/drm/panel/panel-himax-hx8279.c
> index b48b350b62da..4f548430654a 100644
> --- a/drivers/gpu/drm/panel/panel-himax-hx8279.c
> +++ b/drivers/gpu/drm/panel/panel-himax-hx8279.c
> @@ -835,8 +835,7 @@ static int hx8279_check_goa_config(struct hx8279 *hx, struct device *dev)
>   			num_zero++;
>   	}
>   
> -	if (num_zero == ARRAY_SIZE(desc->goa_even_timing))
> -		goa_even_valid = false;
> +	goa_even_valid = (num_zero != ARRAY_SIZE(desc->goa_even_timing));
>   
>   	/* Programming one without the other would make no sense! */
>   	if (goa_odd_valid != goa_even_valid)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable
  2025-04-23 16:32 [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable Arnd Bergmann
  2025-04-23 17:19 ` Dmitry Baryshkov
  2025-04-24  7:21 ` AngeloGioacchino Del Regno
@ 2025-04-24  8:20 ` Neil Armstrong
  2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2025-04-24  8:20 UTC (permalink / raw)
  To: Arnd Bergmann, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	AngeloGioacchino Del Regno
  Cc: Arnd Bergmann, Jessica Zhang, dri-devel, linux-kernel

Hi,

On 23/04/2025 18:32, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> goa_even_valid is only initialized in one branch but not the other:
> 
> drivers/gpu/drm/panel/panel-himax-hx8279.c:838:6: error: variable 'goa_even_valid' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>    838 |         if (num_zero == ARRAY_SIZE(desc->goa_even_timing))
>        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/panel/panel-himax-hx8279.c:842:23: note: uninitialized use occurs here
>    842 |         if (goa_odd_valid != goa_even_valid)
>        |                              ^~~~~~~~~~~~~~
> 
> Change the initialization to set it to the value of the condition instead.
> 
> Fixes: 38d42c261389 ("drm: panel: Add driver for Himax HX8279 DDIC panels")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/gpu/drm/panel/panel-himax-hx8279.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-himax-hx8279.c b/drivers/gpu/drm/panel/panel-himax-hx8279.c
> index b48b350b62da..4f548430654a 100644
> --- a/drivers/gpu/drm/panel/panel-himax-hx8279.c
> +++ b/drivers/gpu/drm/panel/panel-himax-hx8279.c
> @@ -835,8 +835,7 @@ static int hx8279_check_goa_config(struct hx8279 *hx, struct device *dev)
>   			num_zero++;
>   	}
>   
> -	if (num_zero == ARRAY_SIZE(desc->goa_even_timing))
> -		goa_even_valid = false;
> +	goa_even_valid = (num_zero != ARRAY_SIZE(desc->goa_even_timing));
>   
>   	/* Programming one without the other would make no sense! */
>   	if (goa_odd_valid != goa_even_valid)

Thanks, Applying https://lore.kernel.org/all/20250423-panel-himax-hx8279-fix-sometimes-uninitialized-v2-1-fc501c6558d9@kernel.org/
instead since more complete.

Neil

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-24  8:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 16:32 [PATCH] drm: panel: himax-hx8279: avoid using an uninitialized variable Arnd Bergmann
2025-04-23 17:19 ` Dmitry Baryshkov
2025-04-24  7:21 ` AngeloGioacchino Del Regno
2025-04-24  8:20 ` Neil Armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox