Re: [PATCH 12/30] drm/bridge/analogix/anx6345: Cleanup on errors in anx6345_bridge_attach()

2021-03-19 Thread Robert Foss
Hey Lyude,

Thanks for the patch, it looks good to me.

Reviewed-by: Robert Foss 

On Fri, 19 Feb 2021 at 22:58, Lyude Paul  wrote:
>
> Another drive-by fix I found when fixing DP AUX adapter across the kernel
> tree - make sure we don't leak resources (and by proxy-AUX adapters) on
> failures in anx6345_bridge_attach() by unrolling on errors.
>
> Signed-off-by: Lyude Paul 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> index 6258f16da0e8..aa6cda458eb9 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> @@ -550,7 +550,7 @@ static int anx6345_bridge_attach(struct drm_bridge 
> *bridge,
>  DRM_MODE_CONNECTOR_eDP);
> if (err) {
> DRM_ERROR("Failed to initialize connector: %d\n", err);
> -   return err;
> +   goto aux_unregister;
> }
>
> drm_connector_helper_add(>connector,
> @@ -562,16 +562,21 @@ static int anx6345_bridge_attach(struct drm_bridge 
> *bridge,
>bridge->encoder);
> if (err) {
> DRM_ERROR("Failed to link up connector to encoder: %d\n", 
> err);
> -   return err;
> +   goto connector_cleanup;
> }
>
> err = drm_connector_register(>connector);
> if (err) {
> DRM_ERROR("Failed to register connector: %d\n", err);
> -   return err;
> +   goto connector_cleanup;
> }
>
> return 0;
> +connector_cleanup:
> +   drm_connector_cleanup(>connector);
> +aux_unregister:
> +   drm_dp_aux_unregister(>aux);
> +   return err;
>  }
>
>  static void anx6345_bridge_detach(struct drm_bridge *bridge)
> --
> 2.29.2
>


[PATCH 12/30] drm/bridge/analogix/anx6345: Cleanup on errors in anx6345_bridge_attach()

2021-02-19 Thread Lyude Paul
Another drive-by fix I found when fixing DP AUX adapter across the kernel
tree - make sure we don't leak resources (and by proxy-AUX adapters) on
failures in anx6345_bridge_attach() by unrolling on errors.

Signed-off-by: Lyude Paul 
---
 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
index 6258f16da0e8..aa6cda458eb9 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
@@ -550,7 +550,7 @@ static int anx6345_bridge_attach(struct drm_bridge *bridge,
 DRM_MODE_CONNECTOR_eDP);
if (err) {
DRM_ERROR("Failed to initialize connector: %d\n", err);
-   return err;
+   goto aux_unregister;
}
 
drm_connector_helper_add(>connector,
@@ -562,16 +562,21 @@ static int anx6345_bridge_attach(struct drm_bridge 
*bridge,
   bridge->encoder);
if (err) {
DRM_ERROR("Failed to link up connector to encoder: %d\n", err);
-   return err;
+   goto connector_cleanup;
}
 
err = drm_connector_register(>connector);
if (err) {
DRM_ERROR("Failed to register connector: %d\n", err);
-   return err;
+   goto connector_cleanup;
}
 
return 0;
+connector_cleanup:
+   drm_connector_cleanup(>connector);
+aux_unregister:
+   drm_dp_aux_unregister(>aux);
+   return err;
 }
 
 static void anx6345_bridge_detach(struct drm_bridge *bridge)
-- 
2.29.2