Commit 212ee8db authored by Lyude Paul's avatar Lyude Paul

drm/bridge/analogix/anx78xx: Cleanup on error in anx78xx_bridge_attach()

Just another issue I noticed while correcting usages of
drm_dp_aux_init()/drm_dp_aux_register() around the tree. If any of the
steps in anx78xx_bridge_attach() fail, we end up leaking resources. So,
let's fix that (and fix leaking a DP AUX adapter in the process) by
unrolling on errors.
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Reviewed-by: default avatarRobert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219215326.2227596-10-lyude@redhat.com
parent 9962849d
...@@ -918,7 +918,7 @@ static int anx78xx_bridge_attach(struct drm_bridge *bridge, ...@@ -918,7 +918,7 @@ static int anx78xx_bridge_attach(struct drm_bridge *bridge,
DRM_MODE_CONNECTOR_DisplayPort); DRM_MODE_CONNECTOR_DisplayPort);
if (err) { if (err) {
DRM_ERROR("Failed to initialize connector: %d\n", err); DRM_ERROR("Failed to initialize connector: %d\n", err);
return err; goto aux_unregister;
} }
drm_connector_helper_add(&anx78xx->connector, drm_connector_helper_add(&anx78xx->connector,
...@@ -930,16 +930,21 @@ static int anx78xx_bridge_attach(struct drm_bridge *bridge, ...@@ -930,16 +930,21 @@ static int anx78xx_bridge_attach(struct drm_bridge *bridge,
bridge->encoder); bridge->encoder);
if (err) { if (err) {
DRM_ERROR("Failed to link up connector to encoder: %d\n", err); DRM_ERROR("Failed to link up connector to encoder: %d\n", err);
return err; goto connector_cleanup;
} }
err = drm_connector_register(&anx78xx->connector); err = drm_connector_register(&anx78xx->connector);
if (err) { if (err) {
DRM_ERROR("Failed to register connector: %d\n", err); DRM_ERROR("Failed to register connector: %d\n", err);
return err; goto connector_cleanup;
} }
return 0; return 0;
connector_cleanup:
drm_connector_cleanup(&anx78xx->connector);
aux_unregister:
drm_dp_aux_unregister(&anx78xx->aux);
return err;
} }
static void anx78xx_bridge_detach(struct drm_bridge *bridge) static void anx78xx_bridge_detach(struct drm_bridge *bridge)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment