From patchwork Mon Mar 6 10:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 660676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48602C678D4 for ; Mon, 6 Mar 2023 10:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjCFKJb (ORCPT ); Mon, 6 Mar 2023 05:09:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbjCFKJX (ORCPT ); Mon, 6 Mar 2023 05:09:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45ED9222E1; Mon, 6 Mar 2023 02:09:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D1A9160DCA; Mon, 6 Mar 2023 10:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DF96C4339C; Mon, 6 Mar 2023 10:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678097358; bh=X7Gj43NEKH3ef23xjVhwnnWwIQxNkYo2UW1bxn+SqkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c8BncGvgcE6nNUvBtSWfH1uDOZUB3o+kJy7hCuVAqZmnT56FGYwjCf+7FiOFC2lf5 rw8XNSPhLLKA1WlR4/GeruxoZUVT8EZFoiuzpVum5aeg25OF6aLjs00WtOq4aJ5cdh VXVZJo5WogxLOQw6b4Qhcx0MiTP5CtTSQVeS6r13+aXF09RYyyYX27ziBAWBLHZ2Us zIsp6CXnP5hhory3bwWCJLp8pdifROWqwystI2L7qrosrcoviLDutr8oCB3ngtU0nd aTfllirJ+xDBWxgfvFhN6Ng+D7MMDeSm0WLbQ6LV/SPfmzdSiWYDZujFaIlLORnUKY Q0vjuwbcmS8xg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ7n5-0007Ql-C4; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 05/10] drm/msm: fix drm device leak on bind errors Date: Mon, 6 Mar 2023 11:07:17 +0100 Message-Id: <20230306100722.28485-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306100722.28485-1-johan+linaro@kernel.org> References: <20230306100722.28485-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Make sure to free the DRM device also in case of early errors during bind(). Fixes: 2027e5b3413d ("drm/msm: Initialize MDSS irq domain at probe time") Cc: stable@vger.kernel.org # 5.17 Cc: Dmitry Baryshkov Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_drv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 2f2bcdb671d2..89634159ad75 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -444,12 +444,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) ret = msm_init_vram(ddev); if (ret) - return ret; + goto err_put_dev; /* Bind all our sub-components: */ ret = component_bind_all(dev, ddev); if (ret) - return ret; + goto err_put_dev; dma_set_max_seg_size(dev, UINT_MAX); @@ -544,6 +544,12 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) err_msm_uninit: msm_drm_uninit(dev); + + return ret; + +err_put_dev: + drm_dev_put(ddev); + return ret; }