From patchwork Mon Jul 9 17:31:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10515379 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B40A16032A for ; Mon, 9 Jul 2018 17:34:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9998B28D0D for ; Mon, 9 Jul 2018 17:34:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B83828DD3; Mon, 9 Jul 2018 17:34:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 235BD28D0D for ; Mon, 9 Jul 2018 17:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933633AbeGIRe6 (ORCPT ); Mon, 9 Jul 2018 13:34:58 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:39448 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933489AbeGIRe5 (ORCPT ); Mon, 9 Jul 2018 13:34:57 -0400 Received: by mail-yw0-f193.google.com with SMTP id r184-v6so1450901ywg.6 for ; Mon, 09 Jul 2018 10:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=E0bJK7eVGUT/dwDMPFTE4ccO2vzj7OJ1YxRkknW/bzk=; b=OKx3kJeW7fq3khHL+7diypIvG1blaSRUd6LawtaTZSAWmXwU7WV4i7nb5q5u+2/C3X /ho3aKubsne97G5mf/nIFD63kcJskv6HnDNIaIRQLtS4bIRslvT0yyvjf6yNK+eNkyos zZ5tJUpNUZrPVpAvMfEVGcAnOsidO0YY5uUHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=E0bJK7eVGUT/dwDMPFTE4ccO2vzj7OJ1YxRkknW/bzk=; b=rargZiufVV+vkUeW7lNWgdQn4pJDluHXBVlGHuH4EigY7E2Togfi+Z57tiEBJdZcba qgRJ/zsQQyysTTDYwPYboDVER2KX3P00ECY4rpNhWdh8GGLh18r2ZTnKNliFBQGK9oA6 tZwMC/lmQpNlojNBg0O7FIAmWULHpKkmecCQEkkQ4Jhszzx7fF55JS0kEsbGV/8C7OO0 FmoyIQEVMhb8BsaWAeGWFAi5oi9jiHLlcGnYgd9BCXREPzR78dc/aXD2F7mGCzvfxG1W dZWmKvhXoKLoLtfoOQlvHfZwj0y6mRceBlEyyyt8MssI2nqUFDebM7iGIdctuVJAdyl4 XsAQ== X-Gm-Message-State: APt69E0YhSc0H/fYeXiZalcSBvUTXgRG07BxMK3GqkGoTLFMSLBZxP4T MMF/Lq78mDbXPNWTe4czja+hwQ== X-Google-Smtp-Source: AAOMgpeuq2HQQ9CpPF1ItlRVQbu3AIYSJ1MNUOYS3dKn44dh/ZcLCVHUz/OTYJeN9Qz9flayqAiC0Q== X-Received: by 2002:a81:8047:: with SMTP id q68-v6mr10383624ywf.196.1531157697256; Mon, 09 Jul 2018 10:34:57 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id s206-v6sm5885495ywc.55.2018.07.09.10.34.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 10:34:56 -0700 (PDT) From: Sean Paul To: abhinavk@codeaurora.org, architt@codeaurora.org, chandanu@codeaurora.org, jsanka@codeaurora.org, jcrouse@codeaurora.org, ryadav@codeaurora.org, seanpaul@chromium.org, skolluku@codeaurora.org, dri-devel@lists.freedesktop.org, robdclark@gmail.com, airlied@linux.ie, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, nganji@codeaurora.org, hoegsberg@chromium.org, dovizu@chromium.org, robh+dt@kernel.org Subject: [PATCH 14/21] drm/msm: Use labels for unwinding in the error path Date: Mon, 9 Jul 2018 13:31:50 -0400 Message-Id: <20180709173200.238457-15-seanpaul@chromium.org> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog In-Reply-To: <20180709173200.238457-1-seanpaul@chromium.org> References: <20180709173200.238457-1-seanpaul@chromium.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeykumar Sankaran This simplifies cleanup, to make sure nothing drops out in case of error. Signed-off-by: Jeykumar Sankaran [seanpaul split out of dpu megapatch and renamed labels] Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/msm_drv.c | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 67816543a0d7..8bd9fe831968 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -372,19 +372,16 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) { - drm_dev_unref(ddev); - return -ENOMEM; + ret = -ENOMEM; + goto err_unref_drm_dev; } ddev->dev_private = priv; priv->dev = ddev; ret = mdp5_mdss_init(ddev); - if (ret) { - kfree(priv); - drm_dev_unref(ddev); - return ret; - } + if (ret) + goto err_free_priv; mdss = priv->mdss; @@ -399,17 +396,12 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); - if (ret) { - if (mdss && mdss->funcs) - mdss->funcs->destroy(ddev); - kfree(priv); - drm_dev_unref(ddev); - return ret; - } + if (ret) + goto err_destroy_mdss; ret = msm_init_vram(ddev); if (ret) - goto fail; + goto err_msm_uninit; msm_gem_shrinker_init(ddev); @@ -435,7 +427,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) */ dev_err(dev, "failed to load kms\n"); ret = PTR_ERR(kms); - goto fail; + goto err_msm_uninit; } /* Enable normalization of plane zpos */ @@ -445,7 +437,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ret = kms->funcs->hw_init(kms); if (ret) { dev_err(dev, "kms hw init failed: %d\n", ret); - goto fail; + goto err_msm_uninit; } } @@ -455,7 +447,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ret = drm_vblank_init(ddev, priv->num_crtcs); if (ret < 0) { dev_err(dev, "failed to initialize vblank\n"); - goto fail; + goto err_msm_uninit; } if (kms) { @@ -464,13 +456,13 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) pm_runtime_put_sync(dev); if (ret < 0) { dev_err(dev, "failed to install IRQ handler\n"); - goto fail; + goto err_msm_uninit; } } ret = drm_dev_register(ddev, 0); if (ret) - goto fail; + goto err_msm_uninit; drm_mode_config_reset(ddev); @@ -481,15 +473,23 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv) ret = msm_debugfs_late_init(ddev); if (ret) - goto fail; + goto err_msm_uninit; drm_kms_helper_poll_init(ddev); return 0; -fail: +err_msm_uninit: msm_drm_uninit(dev); return ret; +err_destroy_mdss: + if (mdss && mdss->funcs) + mdss->funcs->destroy(ddev); +err_free_priv: + kfree(priv); +err_unref_drm_dev: + drm_dev_unref(ddev); + return ret; } /*