Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8348166pxb; Fri, 19 Feb 2021 13:58:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJymxTJMqeOc8nPNfZc9PjVc0I4HEZd1/aiSEDJmBbBsx2BqQPmCgPHK+ky/5dDGWKW2rS+I X-Received: by 2002:aa7:c94c:: with SMTP id h12mr11619709edt.40.1613771927409; Fri, 19 Feb 2021 13:58:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613771927; cv=none; d=google.com; s=arc-20160816; b=ZHZMtOvXI2tXTYJRdwBCY0n0mrhThbpZuweta6xIU3sUzcQUghizAZKR8V7tQ5L2ZN 33k0WQ0j1A5JfYjV31i9J3UeL7OorFb1ZhBFIchasEzUh1ZDZzbhP/sSEn250+KJ7py3 qDlJtvVrVmAaqE+GaoojGmIuE1R+5g0AZeSHjWSFJ2qLwAmHvBilhmT+bb0t5cQzK13x d2BOwGzvWfDTJWCMKX8vcjb34z7c2MV1jCwPf5PT4T/6c6wmbygxOBBPUfm8qbnGTLaS SsvH66giyrTLt1jn0anMGISAyjU2ymBAk9giAOo5k111X8OL9A1loH4H0mr0TErzM/vT dmZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yqrvg6oBBIK95MSB53UzOrhjDOM9evvbR5uL/I7AFzg=; b=LA3fiTzXrPoKzT4zbnB6cdLUzql8Omfikzvxz2FG6RWiGz9exr/N+ZD0gcwlVLRNrQ 84WkE7FGDI8cCZdCmeCwvAzTCtTnHIa5UiI/hxZagzwLeCLR5zdtsnsr+yya9F5a+NWj F6eIeAVW5OFBhmqQ3eP+1JqcdYy94nRBRtRqEPx1YnOPBSTQwEjyXYqMewBlB9TxYaXw xZdU/ag5xT7lOt3UnfcBMTjeCTtQtTwrT1rSxakd3+mVLyL9OcMHZwI1JxlMaCzaJ3cy 6m9/2YMiL/XsxSFSxs2UeHS3k0bR+tfVeGevSNWqkGYY4lO58a34uw5ojRBQJSxurQvm 5Oxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="U/gHMewJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si7789874ejo.142.2021.02.19.13.58.24; Fri, 19 Feb 2021 13:58:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="U/gHMewJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbhBSV41 (ORCPT + 99 others); Fri, 19 Feb 2021 16:56:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58195 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbhBSVzr (ORCPT ); Fri, 19 Feb 2021 16:55:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613771660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yqrvg6oBBIK95MSB53UzOrhjDOM9evvbR5uL/I7AFzg=; b=U/gHMewJB6JVLsPv3FEHu1r/opq+Mfehc5jxbzdj7uNpd/jLIvzH53FsJ5yCyg7y/wUjR7 EDVR56C+mGxUrGONlUiPEAbxajnNnGO8999unuVJBpAzeX6B3x4tUNnyidLSEs3xrOb6wj LtziGzmzuVKo9fteKLytip/gbq7r/Co= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-kCi7ec4_OfiPnys6rI3Mtg-1; Fri, 19 Feb 2021 16:54:16 -0500 X-MC-Unique: kCi7ec4_OfiPnys6rI3Mtg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3B1DDF8DD; Fri, 19 Feb 2021 21:54:13 +0000 (UTC) Received: from Whitewolf.redhat.com (ovpn-118-5.rdu2.redhat.com [10.10.118.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id C030D6A03C; Fri, 19 Feb 2021 21:54:11 +0000 (UTC) From: Lyude Paul To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Jani Nikula , Rodrigo Vivi , Thomas Zimmermann Cc: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Boris Brezillon , Tomi Valkeinen , Sam Ravnborg , Torsten Duwe , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 09/30] drm/bridge/analogix/anx78xx: Cleanup on error in anx78xx_bridge_attach() Date: Fri, 19 Feb 2021 16:53:05 -0500 Message-Id: <20210219215326.2227596-10-lyude@redhat.com> In-Reply-To: <20210219215326.2227596-1-lyude@redhat.com> References: <20210219215326.2227596-1-lyude@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c index 338dd8531d4b..f20558618220 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c @@ -918,7 +918,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, @@ -930,16 +930,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 void anx78xx_bridge_detach(struct drm_bridge *bridge) -- 2.29.2