From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
dri-devel@lists.freedesktop.org,
Robert Foss <robert.foss@linaro.org>
Subject: [PATCH AUTOSEL 4.19 13/35] drm/bridge/analogix/anx78xx: Cleanup on error in anx78xx_bridge_attach()
Date: Mon, 3 May 2021 12:40:47 -0400 [thread overview]
Message-ID: <20210503164109.2853838-13-sashal@kernel.org> (raw)
In-Reply-To: <20210503164109.2853838-1-sashal@kernel.org>
From: Lyude Paul <lyude@redhat.com>
[ Upstream commit 212ee8db84600f7b279b8645c62a112bff310995 ]
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: Lyude Paul <lyude@redhat.com>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219215326.2227596-10-lyude@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/bridge/analogix-anx78xx.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/bridge/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix-anx78xx.c
index 9fa1610b237a..84a261c1b54f 100644
--- a/drivers/gpu/drm/bridge/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c
@@ -1036,7 +1036,7 @@ static int anx78xx_bridge_attach(struct drm_bridge *bridge)
DRM_MODE_CONNECTOR_DisplayPort);
if (err) {
DRM_ERROR("Failed to initialize connector: %d\n", err);
- return err;
+ goto aux_unregister;
}
drm_connector_helper_add(&anx78xx->connector,
@@ -1048,16 +1048,21 @@ static int anx78xx_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(&anx78xx->connector);
if (err) {
DRM_ERROR("Failed to register connector: %d\n", err);
- return err;
+ goto connector_cleanup;
}
return 0;
+connector_cleanup:
+ drm_connector_cleanup(&anx78xx->connector);
+aux_unregister:
+ drm_dp_aux_unregister(&anx78xx->aux);
+ return err;
}
static enum drm_mode_status
--
2.30.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2021-05-03 16:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210503164109.2853838-1-sashal@kernel.org>
2021-05-03 16:40 ` [PATCH AUTOSEL 4.19 12/35] drm/bridge/analogix/anx78xx: Setup encoder before registering connector Sasha Levin
2021-05-03 16:40 ` Sasha Levin [this message]
2021-05-03 16:40 ` [PATCH AUTOSEL 4.19 14/35] drm/amdgpu : Fix asic reset regression issue introduce by 8f211fe8ac7c4f Sasha Levin
2021-05-03 16:41 ` [PATCH AUTOSEL 4.19 29/35] drm/msm/mdp5: Configure PP_SYNC_HEIGHT to double the vtotal Sasha Levin
2021-05-03 16:41 ` [PATCH AUTOSEL 4.19 30/35] amdgpu: avoid incorrect %hu format string Sasha Levin
2021-05-03 16:41 ` [PATCH AUTOSEL 4.19 31/35] drm/amdgpu: fix NULL pointer dereference Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210503164109.2853838-13-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robert.foss@linaro.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).