drm/bridge/analogix/anx6345: Cleanup on errors in anx6345_bridge_attach()
authorLyude Paul <lyude@redhat.com>
Fri, 19 Feb 2021 21:53:08 +0000 (16:53 -0500)
committerLyude Paul <lyude@redhat.com>
Tue, 23 Mar 2021 18:19:33 +0000 (14:19 -0400)
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 <lyude@redhat.com>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219215326.2227596-13-lyude@redhat.com
drivers/gpu/drm/bridge/analogix/analogix-anx6345.c

index 6258f16..aa6cda4 100644 (file)
@@ -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(&anx6345->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(&anx6345->connector);
        if (err) {
                DRM_ERROR("Failed to register connector: %d\n", err);
-               return err;
+               goto connector_cleanup;
        }
 
        return 0;
+connector_cleanup:
+       drm_connector_cleanup(&anx6345->connector);
+aux_unregister:
+       drm_dp_aux_unregister(&anx6345->aux);
+       return err;
 }
 
 static void anx6345_bridge_detach(struct drm_bridge *bridge)