Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22BC2C433ED for ; Mon, 3 May 2021 16:43:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D981D6196C for ; Mon, 3 May 2021 16:43:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D981D6196C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF8246E9C8; Mon, 3 May 2021 16:43:07 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE5686E9C3 for ; Mon, 3 May 2021 16:43:05 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id D1FDB61968; Mon, 3 May 2021 16:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620060185; bh=Jfb5JeDNXq6MV6xxiZm35fU9ECYIkOD6TvYYV7P1sFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E42aGjpWUzvpc795+n77zPX7btmeCRrn+ShRmEn/asElUSYscQ4/qarL1cXHLDUhy NS5bhAzd38LcUYT0Vkk0E+dtrGNEpijUlo4rpN1Cx2Ef2g4W766KQxAMkoyuUj1sOO 1zXC5t52qn9/wqupR/yoBtR7dXxyrPKj4OLjHHi8Zg5QMasxZEWaXYhrM2NH1Zb/7q ZYZMDv9YIwJC3WrXBuUJz4mgeSjJz02xgSKFY+uLz9Uyz9ZcoO70iEjcUBIMVsmX/Y jap8BdafONLZqVLtlUh1oBKR7OY+q3a5/22EU2RPTpSbn8dVa3JcR993u89dQJOxz7 1YlNuFhmYVrtw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 09/24] drm/bridge/analogix/anx78xx: Cleanup on error in anx78xx_bridge_attach() Date: Mon, 3 May 2021 12:42:37 -0400 Message-Id: <20210503164252.2854487-9-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210503164252.2854487-1-sashal@kernel.org> References: <20210503164252.2854487-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , dri-devel@lists.freedesktop.org, Robert Foss Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Lyude Paul [ 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 Reviewed-by: Robert Foss Link: https://patchwork.freedesktop.org/patch/msgid/20210219215326.2227596-10-lyude@redhat.com Signed-off-by: Sasha Levin --- 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 16babacb7cf0..5a1121af6664 100644 --- a/drivers/gpu/drm/bridge/analogix-anx78xx.c +++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c @@ -1039,7 +1039,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, @@ -1051,16 +1051,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 bool anx78xx_bridge_mode_fixup(struct drm_bridge *bridge, -- 2.30.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel