All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
@ 2022-06-13 16:37 ` Nícolas F. R. A. Prado
  0 siblings, 0 replies; 8+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-06-13 16:37 UTC (permalink / raw)
  To: Robert Foss
  Cc: Andrzej Hajda, Nícolas F. R. A. Prado, Jonas Karlman,
	David Airlie, Thomas Zimmermann, dri-devel, Neil Armstrong,
	linux-kernel, Jernej Skrabec, Tzung-Bi Shih, Laurent Pinchart,
	Hsin-Yi Wang, José Expósito, Maxime Ripard, kernel,
	Sam Ravnborg, Xin Ji, AngeloGioacchino Del Regno

While parsing the DT, the anx7625 driver checks for the presence of a
panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
the error pointer and the function returns successfully without first
cleaning that variable. This is an issue since other functions later
check for the presence of a panel bridge by testing the trueness of that
variable.

In order to ensure proper behavior, zero out pdata->panel_bridge before
returning when no panel bridge is found.

Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

---

 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 53a5da6c49dd..3aed4de16690 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1657,8 +1657,10 @@ static int anx7625_parse_dt(struct device *dev,
 
 	pdata->panel_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);
 	if (IS_ERR(pdata->panel_bridge)) {
-		if (PTR_ERR(pdata->panel_bridge) == -ENODEV)
+		if (PTR_ERR(pdata->panel_bridge) == -ENODEV) {
+			pdata->panel_bridge = NULL;
 			return 0;
+		}
 
 		return PTR_ERR(pdata->panel_bridge);
 	}
-- 
2.36.1


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

* [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
@ 2022-06-13 16:37 ` Nícolas F. R. A. Prado
  0 siblings, 0 replies; 8+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-06-13 16:37 UTC (permalink / raw)
  To: Robert Foss
  Cc: kernel, AngeloGioacchino Del Regno, Nícolas F. R. A. Prado,
	Andrzej Hajda, Daniel Vetter, David Airlie, Hsin-Yi Wang,
	Jernej Skrabec, Jonas Karlman, José Expósito,
	Laurent Pinchart, Maxime Ripard, Neil Armstrong, Sam Ravnborg,
	Thomas Zimmermann, Tzung-Bi Shih, Xin Ji, dri-devel,
	linux-kernel

While parsing the DT, the anx7625 driver checks for the presence of a
panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
the error pointer and the function returns successfully without first
cleaning that variable. This is an issue since other functions later
check for the presence of a panel bridge by testing the trueness of that
variable.

In order to ensure proper behavior, zero out pdata->panel_bridge before
returning when no panel bridge is found.

Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

---

 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 53a5da6c49dd..3aed4de16690 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1657,8 +1657,10 @@ static int anx7625_parse_dt(struct device *dev,
 
 	pdata->panel_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);
 	if (IS_ERR(pdata->panel_bridge)) {
-		if (PTR_ERR(pdata->panel_bridge) == -ENODEV)
+		if (PTR_ERR(pdata->panel_bridge) == -ENODEV) {
+			pdata->panel_bridge = NULL;
 			return 0;
+		}
 
 		return PTR_ERR(pdata->panel_bridge);
 	}
-- 
2.36.1


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

* Re: [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
  2022-06-13 16:37 ` Nícolas F. R. A. Prado
@ 2022-06-13 17:30   ` José Expósito
  -1 siblings, 0 replies; 8+ messages in thread
From: José Expósito @ 2022-06-13 17:30 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: Laurent Pinchart, Andrzej Hajda, Maxime Ripard, Jonas Karlman,
	David Airlie, Thomas Zimmermann, dri-devel, Neil Armstrong,
	linux-kernel, Robert Foss, Tzung-Bi Shih, Jernej Skrabec,
	Hsin-Yi Wang, kernel, Sam Ravnborg, Xin Ji,
	AngeloGioacchino Del Regno

On Mon, Jun 13, 2022 at 12:37:05PM -0400, Nícolas F. R. A. Prado wrote:
> While parsing the DT, the anx7625 driver checks for the presence of a
> panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
> the error pointer and the function returns successfully without first
> cleaning that variable. This is an issue since other functions later
> check for the presence of a panel bridge by testing the trueness of that
> variable.
> 
> In order to ensure proper behavior, zero out pdata->panel_bridge before
> returning when no panel bridge is found.
> 
> Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 
> ---
> 
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 53a5da6c49dd..3aed4de16690 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -1657,8 +1657,10 @@ static int anx7625_parse_dt(struct device *dev,
>  
>  	pdata->panel_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);
>  	if (IS_ERR(pdata->panel_bridge)) {
> -		if (PTR_ERR(pdata->panel_bridge) == -ENODEV)
> +		if (PTR_ERR(pdata->panel_bridge) == -ENODEV) {
> +			pdata->panel_bridge = NULL;
>  			return 0;
> +		}
>  
>  		return PTR_ERR(pdata->panel_bridge);
>  	}
> -- 
> 2.36.1
> 

Thanks for spotting this error Nícolas. As you mentioned, prior to
9e82ea0fb1df the "pdata->panel_bridge" pointer was not modified
(i.e. left to NULL) on the ENODEV error branch.

I missed it during the refactor, sorry about that.

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

* Re: [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
@ 2022-06-13 17:30   ` José Expósito
  0 siblings, 0 replies; 8+ messages in thread
From: José Expósito @ 2022-06-13 17:30 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: Robert Foss, kernel, AngeloGioacchino Del Regno, Andrzej Hajda,
	Daniel Vetter, David Airlie, Hsin-Yi Wang, Jernej Skrabec,
	Jonas Karlman, Laurent Pinchart, Maxime Ripard, Neil Armstrong,
	Sam Ravnborg, Thomas Zimmermann, Tzung-Bi Shih, Xin Ji,
	dri-devel, linux-kernel

On Mon, Jun 13, 2022 at 12:37:05PM -0400, Nícolas F. R. A. Prado wrote:
> While parsing the DT, the anx7625 driver checks for the presence of a
> panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
> the error pointer and the function returns successfully without first
> cleaning that variable. This is an issue since other functions later
> check for the presence of a panel bridge by testing the trueness of that
> variable.
> 
> In order to ensure proper behavior, zero out pdata->panel_bridge before
> returning when no panel bridge is found.
> 
> Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 
> ---
> 
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 53a5da6c49dd..3aed4de16690 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -1657,8 +1657,10 @@ static int anx7625_parse_dt(struct device *dev,
>  
>  	pdata->panel_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);
>  	if (IS_ERR(pdata->panel_bridge)) {
> -		if (PTR_ERR(pdata->panel_bridge) == -ENODEV)
> +		if (PTR_ERR(pdata->panel_bridge) == -ENODEV) {
> +			pdata->panel_bridge = NULL;
>  			return 0;
> +		}
>  
>  		return PTR_ERR(pdata->panel_bridge);
>  	}
> -- 
> 2.36.1
> 

Thanks for spotting this error Nícolas. As you mentioned, prior to
9e82ea0fb1df the "pdata->panel_bridge" pointer was not modified
(i.e. left to NULL) on the ENODEV error branch.

I missed it during the refactor, sorry about that.

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

* Re: [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
  2022-06-13 16:37 ` Nícolas F. R. A. Prado
@ 2022-06-14  7:52   ` AngeloGioacchino Del Regno
  -1 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-06-14  7:52 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Robert Foss
  Cc: Andrzej Hajda, Jonas Karlman, David Airlie, Thomas Zimmermann,
	dri-devel, Neil Armstrong, linux-kernel, Jernej Skrabec,
	Tzung-Bi Shih, Laurent Pinchart, Hsin-Yi Wang,
	José Expósito, kernel, Sam Ravnborg, Xin Ji,
	Maxime Ripard

Il 13/06/22 18:37, Nícolas F. R. A. Prado ha scritto:
> While parsing the DT, the anx7625 driver checks for the presence of a
> panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
> the error pointer and the function returns successfully without first
> cleaning that variable. This is an issue since other functions later
> check for the presence of a panel bridge by testing the trueness of that
> variable.
> 
> In order to ensure proper behavior, zero out pdata->panel_bridge before
> returning when no panel bridge is found.
> 
> Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 

I would've preferred s/zero out/cleanup/g but it's also fine as you wrote it.
Besides, good catch!

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


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

* Re: [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
@ 2022-06-14  7:52   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-06-14  7:52 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Robert Foss
  Cc: kernel, Andrzej Hajda, Daniel Vetter, David Airlie, Hsin-Yi Wang,
	Jernej Skrabec, Jonas Karlman, José Expósito,
	Laurent Pinchart, Maxime Ripard, Neil Armstrong, Sam Ravnborg,
	Thomas Zimmermann, Tzung-Bi Shih, Xin Ji, dri-devel,
	linux-kernel

Il 13/06/22 18:37, Nícolas F. R. A. Prado ha scritto:
> While parsing the DT, the anx7625 driver checks for the presence of a
> panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
> the error pointer and the function returns successfully without first
> cleaning that variable. This is an issue since other functions later
> check for the presence of a panel bridge by testing the trueness of that
> variable.
> 
> In order to ensure proper behavior, zero out pdata->panel_bridge before
> returning when no panel bridge is found.
> 
> Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 

I would've preferred s/zero out/cleanup/g but it's also fine as you wrote it.
Besides, good catch!

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


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

* Re: [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
  2022-06-14  7:52   ` AngeloGioacchino Del Regno
@ 2022-06-15 16:04     ` Robert Foss
  -1 siblings, 0 replies; 8+ messages in thread
From: Robert Foss @ 2022-06-15 16:04 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: Nícolas F. R. A. Prado, kernel, Andrzej Hajda,
	Daniel Vetter, David Airlie, Hsin-Yi Wang, Jernej Skrabec,
	Jonas Karlman, José Expósito, Laurent Pinchart,
	Maxime Ripard, Neil Armstrong, Sam Ravnborg, Thomas Zimmermann,
	Tzung-Bi Shih, Xin Ji, dri-devel, linux-kernel

On Tue, 14 Jun 2022 at 09:52, AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> wrote:
>
> Il 13/06/22 18:37, Nícolas F. R. A. Prado ha scritto:
> > While parsing the DT, the anx7625 driver checks for the presence of a
> > panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
> > the error pointer and the function returns successfully without first
> > cleaning that variable. This is an issue since other functions later
> > check for the presence of a panel bridge by testing the trueness of that
> > variable.
> >
> > In order to ensure proper behavior, zero out pdata->panel_bridge before
> > returning when no panel bridge is found.
> >
> > Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
> > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> >
>
> I would've preferred s/zero out/cleanup/g but it's also fine as you wrote it.
> Besides, good catch!
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>

Applied to drm-misc-next

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

* Re: [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present
@ 2022-06-15 16:04     ` Robert Foss
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Foss @ 2022-06-15 16:04 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: Andrzej Hajda, Nícolas F. R. A. Prado, Jonas Karlman,
	David Airlie, Thomas Zimmermann, dri-devel, Neil Armstrong,
	linux-kernel, Jernej Skrabec, Tzung-Bi Shih, Laurent Pinchart,
	Hsin-Yi Wang, José Expósito, kernel, Sam Ravnborg,
	Xin Ji, Maxime Ripard

On Tue, 14 Jun 2022 at 09:52, AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> wrote:
>
> Il 13/06/22 18:37, Nícolas F. R. A. Prado ha scritto:
> > While parsing the DT, the anx7625 driver checks for the presence of a
> > panel bridge on endpoint 1. If it is missing, pdata->panel_bridge stores
> > the error pointer and the function returns successfully without first
> > cleaning that variable. This is an issue since other functions later
> > check for the presence of a panel bridge by testing the trueness of that
> > variable.
> >
> > In order to ensure proper behavior, zero out pdata->panel_bridge before
> > returning when no panel bridge is found.
> >
> > Fixes: 9e82ea0fb1df ("drm/bridge: anx7625: switch to devm_drm_of_get_bridge")
> > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> >
>
> I would've preferred s/zero out/cleanup/g but it's also fine as you wrote it.
> Besides, good catch!
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>

Applied to drm-misc-next

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

end of thread, other threads:[~2022-06-15 16:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 16:37 [PATCH] drm/bridge: anx7625: Zero error variable when panel bridge not present Nícolas F. R. A. Prado
2022-06-13 16:37 ` Nícolas F. R. A. Prado
2022-06-13 17:30 ` José Expósito
2022-06-13 17:30   ` José Expósito
2022-06-14  7:52 ` AngeloGioacchino Del Regno
2022-06-14  7:52   ` AngeloGioacchino Del Regno
2022-06-15 16:04   ` Robert Foss
2022-06-15 16:04     ` Robert Foss

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.