mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"johan@kernel.org" <johan@kernel.org>
Cc: "simona@ffwll.ch" <simona@ffwll.ch>,
	"make24@iscas.ac.cn" <make24@iscas.ac.cn>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH 2/2] drm/mediatek: clean up driver data initialisation
Date: Wed, 10 Sep 2025 01:38:12 +0000	[thread overview]
Message-ID: <c4137f43453ee9ae17592dd230426f26e338f0d8.camel@mediatek.com> (raw)
In-Reply-To: <20250829090345.21075-3-johan@kernel.org>

On Fri, 2025-08-29 at 11:03 +0200, Johan Hovold wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> 
> 
> The platform and drm devices are only used to look up the drm device and
> its driver data respectively when initialising the driver data during
> bind().
> 
> Drop the reference counts as soon as they have been used to make the
> code more readable.
> 
> Note that the crtc count is never incremented on lookup failures.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 3b02ed0a16da..33b83576af7e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -395,12 +395,14 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
>                         continue;
> 
>                 drm_dev = device_find_child(&pdev->dev, NULL, mtk_drm_match);
> +               put_device(&pdev->dev);
>                 if (!drm_dev)
> -                       goto next_put_device_pdev_dev;
> +                       continue;
> 
>                 temp_drm_priv = dev_get_drvdata(drm_dev);
> +               put_device(drm_dev);
>                 if (!temp_drm_priv)
> -                       goto next_put_device_drm_dev;
> +                       continue;
> 
>                 if (temp_drm_priv->data->main_len)
>                         all_drm_priv[CRTC_MAIN] = temp_drm_priv;
> @@ -412,12 +414,6 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
>                 if (temp_drm_priv->mtk_drm_bound)
>                         cnt++;
> 
> -next_put_device_drm_dev:
> -               put_device(drm_dev);
> -
> -next_put_device_pdev_dev:
> -               put_device(&pdev->dev);
> -
>                 if (cnt == MAX_CRTC) {
>                         of_node_put(node);
>                         break;
> --
> 2.49.1
> 


  reply	other threads:[~2025-09-10  1:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29  9:03 [PATCH 0/2] drm/mediatek: fix potential OF node use-after-free Johan Hovold
2025-08-29  9:03 ` [PATCH 1/2] " Johan Hovold
2025-09-08  3:41   ` CK Hu (胡俊光)
2025-08-29  9:03 ` [PATCH 2/2] drm/mediatek: clean up driver data initialisation Johan Hovold
2025-09-10  1:38   ` CK Hu (胡俊光) [this message]
2025-09-10  9:33 ` [PATCH 0/2] drm/mediatek: fix potential OF node use-after-free AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4137f43453ee9ae17592dd230426f26e338f0d8.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=johan@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=make24@iscas.ac.cn \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®