Message ID | 20230306100722.28485-6-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1755840wrd; Mon, 6 Mar 2023 02:11:13 -0800 (PST) X-Google-Smtp-Source: AK7set8HDJDplmxbQ33saYA4/jvbFT8C+pmQ6XYQHFtJUfC4sKE5Ozy2jWdTbgmBu5nIoE/mvc/s X-Received: by 2002:a17:906:d9c8:b0:8e1:cc38:6ab0 with SMTP id qk8-20020a170906d9c800b008e1cc386ab0mr9105304ejb.16.1678097473655; Mon, 06 Mar 2023 02:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678097473; cv=none; d=google.com; s=arc-20160816; b=o2ixLa/mM2B97PyZ1jcnOu+XyVrv1xcbe/h6Ff+h2MAFuc3EawAkKtYUh/hUGDYXIA xPiuu2/8zeVhOtXN06pns0kt536+i15FMrduvOYHGAfh/yZQ10c2SgMX1fGhKLnm+T21 1iTUsa2u0A2o2Jd1Rk0xFCbDtBsHa2pnANJTINQXalUmwH2chvjSnatKCGyKMK6zcLT9 7Z6Ur/iPu1S4RwyQ9MgQPaX2jCKyXJH8rO/YGmD31lLlaM/ADSdCpckLYhia/QXZo55H shhDYucrzB6h+rKi9Qeu0jRYhbmKWePbIJhCJvkkMDolkIneCtRSPuo13geu5AMwED2x 5mVg== 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=d1bG9iQrBnEURa54NtoxMejeWDHLeDJA0izjTL7T3IQ=; b=AxzVY6EShlXdPTUuNV8z1hZKm42ncGmR/mfBeZL8JXefytha4T4g3PZ3BIRJ2hA18y NdKTEOF8LOihkLuqgZyWsHDWV3q+N0h8Z+7N99OX0V0MN7rTN8wG4qcAiHv3d4/Y839R FYGbaAqTIjQieI5RK5WGlO83jT6hcwefxkQ/RQ3h2elhtVMpEfaq+WWTov12yvGztrCb kPUdXVM1jVTDMAPYv8jyS0i9DdKdw+WrxwmpCQYpn2+ynvPgL0ZpULWp/eaSEAgtKuG5 J5tkV3AfOw+6E+krjU+ZVjiyuKZQEn3sH4NbmCVObyq/ZAqlUG6rmKp27MZPZdNV2xvI cB4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c8BncGvg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kd2-20020a17090798c200b008e5082870a9si9438571ejc.574.2023.03.06.02.10.49; Mon, 06 Mar 2023 02:11:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c8BncGvg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbjCFKJv (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 05:09:51 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <johan+linaro@kernel.org>) id 1pZ7n5-0007Ql-C4; Mon, 06 Mar 2023 11:09:59 +0100 From: Johan Hovold <johan+linaro@kernel.org> To: Rob Clark <robdclark@gmail.com>, Abhinav Kumar <quic_abhinavk@quicinc.com>, Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Cc: Sean Paul <sean@poorly.run>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759612736691203049?= X-GMAIL-MSGID: =?utf-8?q?1759612736691203049?= |
Series |
drm/msm: fix bind error handling
|
|
Commit Message
Johan Hovold
March 6, 2023, 10:07 a.m. UTC
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 <dmitry.baryshkov@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/gpu/drm/msm/msm_drv.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Comments
On 06/03/2023 12:07, Johan Hovold wrote: > 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 <dmitry.baryshkov@linaro.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Can we migrate to devm_drm_dev_alloc instead() ? Will it make code simpler and/or easier to handle? > --- > 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; > } >
On Tue, Mar 21, 2023 at 04:54:51PM +0200, Dmitry Baryshkov wrote: > On 06/03/2023 12:07, Johan Hovold wrote: > > 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 <dmitry.baryshkov@linaro.org> > > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > > Can we migrate to devm_drm_dev_alloc instead() ? Will it make code > simpler and/or easier to handle? I'm just fixing the bugs here. Cleanups/rework like that can be done on top but should not be backported as it risks introducing new issues. Johan
On Wed, 22 Mar 2023 at 09:46, Johan Hovold <johan@kernel.org> wrote: > > On Tue, Mar 21, 2023 at 04:54:51PM +0200, Dmitry Baryshkov wrote: > > On 06/03/2023 12:07, Johan Hovold wrote: > > > 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 <dmitry.baryshkov@linaro.org> > > > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > > > > Can we migrate to devm_drm_dev_alloc instead() ? Will it make code > > simpler and/or easier to handle? > > I'm just fixing the bugs here. Cleanups/rework like that can be done on > top but should not be backported as it risks introducing new issues. Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
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; }