From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 76E3DC433DF for ; Mon, 22 Jun 2020 20:08:13 +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 4AD3520767 for ; Mon, 22 Jun 2020 20:08:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BiomHC7D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AD3520767 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 58E8F6E8F8; Mon, 22 Jun 2020 20:08:10 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D0B46E900 for ; Mon, 22 Jun 2020 20:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592856484; 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=2CIqn4trdXaLo6esz2Y3GWcQ2dIBeOVeLn2zbN8dxlA=; b=BiomHC7DPQrsFemb8VpDgK9bEf9qotp9SKirwZK/Z1E6q0B02/Q95dqYmQ9tAEqcPHkWvP +q2lpwUEVsUBVkSJ/rkeJcAycm65mu7KO5DCKpGslhpe80EyLOIpE8Uy2Ep5nroy1x/dda KWdju5knVv4zqJhZQZaLQoNzP5iKig0= 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-304-8MzKhC3HPbKMzRnLmhXKVA-1; Mon, 22 Jun 2020 16:08:03 -0400 X-MC-Unique: 8MzKhC3HPbKMzRnLmhXKVA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A068A464; Mon, 22 Jun 2020 20:08:01 +0000 (UTC) Received: from Whitewolf.redhat.com (ovpn-117-166.rdu2.redhat.com [10.10.117.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56B355C1BD; Mon, 22 Jun 2020 20:08:00 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [RFC v5 03/10] drm/nouveau/kms/nv50-: Unroll error cleanup in nv50_head_create() Date: Mon, 22 Jun 2020 16:07:23 -0400 Message-Id: <20200622200730.120716-4-lyude@redhat.com> In-Reply-To: <20200622200730.120716-1-lyude@redhat.com> References: <20200622200730.120716-1-lyude@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: David Airlie , open list , Ben Skeggs , Thomas Zimmermann , Alex Deucher Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We'll be rolling back more things in this function, and the way it's structured is a bit confusing. So, let's clean this up a bit and just unroll in the event of failure. Signed-off-by: Lyude Paul --- drivers/gpu/drm/nouveau/dispnv50/head.c | 33 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c index 8f6455697ba72..e29ea40e7c334 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/head.c +++ b/drivers/gpu/drm/nouveau/dispnv50/head.c @@ -507,20 +507,28 @@ nv50_head_create(struct drm_device *dev, int index) if (disp->disp->object.oclass < GV100_DISP) { ret = nv50_base_new(drm, head->base.index, &base); + if (ret) + goto fail_free; + ret = nv50_ovly_new(drm, head->base.index, &ovly); + if (ret) + goto fail_free; } else { ret = nv50_wndw_new(drm, DRM_PLANE_TYPE_PRIMARY, head->base.index * 2 + 0, &base); + if (ret) + goto fail_free; + ret = nv50_wndw_new(drm, DRM_PLANE_TYPE_OVERLAY, head->base.index * 2 + 1, &ovly); - } - if (ret == 0) - ret = nv50_curs_new(drm, head->base.index, &curs); - if (ret) { - kfree(head); - return ERR_PTR(ret); + if (ret) + goto fail_free; } + ret = nv50_curs_new(drm, head->base.index, &curs); + if (ret) + goto fail_free; + crtc = &head->base.base; drm_crtc_init_with_planes(dev, crtc, &base->plane, &curs->plane, &nv50_head_func, "head-%d", head->base.index); @@ -533,11 +541,16 @@ nv50_head_create(struct drm_device *dev, int index) if (head->func->olut_set) { ret = nv50_lut_init(disp, &drm->client.mmu, &head->olut); - if (ret) { - nv50_head_destroy(crtc); - return ERR_PTR(ret); - } + if (ret) + goto fail_crtc_cleanup; } return head; + +fail_crtc_cleanup: + drm_crtc_cleanup(crtc); +fail_free: + kfree(head); + + return ERR_PTR(ret); } -- 2.26.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel