From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Felix Gu <ustc.gu@gmail.com>
Cc: Rob Clark <robin.clark@oss.qualcomm.com>,
Sean Paul <sean@poorly.run>,
Konrad Dybcio <konradybcio@kernel.org>,
Akhil P Oommen <akhilpo@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Marijn Suijten <marijn.suijten@somainline.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/msm/adreno: Fix a reference leak in a6xx_gpu_init()
Date: Fri, 23 Jan 2026 20:23:23 +0200 [thread overview]
Message-ID: <e62971cd-ed56-46a3-ab47-46f3523ceeff@oss.qualcomm.com> (raw)
In-Reply-To: <CAN4SLj3=N0ACXLKbTe1HCjQXuO4GuG+TXEXYjhO-g=u8Y_uKjA@mail.gmail.com>
On 23/01/2026 20:21, Felix Gu wrote:
> Hi Dmitry,
> Thanks for your review.
> linux/cleanup.h is included in linux/of.h.
> So it should be included already.
Yes. However we should not depend on include files being provided by
other kernel-wide includes.
Also, please don't top-post when replying to the emails on public MLs.
>
> Best regards,
> Feix Gu
>
> On Sat, Jan 24, 2026 at 1:58 AM Dmitry Baryshkov
> <dmitry.baryshkov@oss.qualcomm.com> wrote:
>>
>> On Sat, Jan 24, 2026 at 12:37:38AM +0800, Felix Gu wrote:
>>> In a6xx_gpu_init(), node is obtained via of_parse_phandle().
>>> While there was a manual of_node_put() at the end of the
>>> common path, several early error returns would bypass this call,
>>> resulting in a reference leak.
>>> Fix this by using the __free(device_node) cleanup handler to
>>> release the reference when the variable goes out of scope.
>>>
>>> Fixes: 5a903a44a984 ("drm/msm/a6xx: Introduce GMU wrapper support")
>>> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
>>> ---
>>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 5 ++---
>>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>> index 2129d230a92b..0bc518d9fd65 100644
>>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>>> @@ -2640,7 +2640,6 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
>>> struct msm_drm_private *priv = dev->dev_private;
>>> struct platform_device *pdev = priv->gpu_pdev;
>>> struct adreno_platform_config *config = pdev->dev.platform_data;
>>> - struct device_node *node;
>>> struct a6xx_gpu *a6xx_gpu;
>>> struct adreno_gpu *adreno_gpu;
>>> struct msm_gpu *gpu;
>>> @@ -2660,7 +2659,8 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
>>> adreno_gpu->registers = NULL;
>>>
>>> /* Check if there is a GMU phandle and set it up */
>>> - node = of_parse_phandle(pdev->dev.of_node, "qcom,gmu", 0);
>>> + struct device_node *node __free(device_node) =
>>> + of_parse_phandle(pdev->dev.of_node, "qcom,gmu", 0);
>>
>> Missing include for cleanup.h.
>>
>>> /* FIXME: How do we gracefully handle this? */
>>> BUG_ON(!node);
>>>
>>> @@ -2702,7 +2702,6 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
>>> ret = a6xx_gmu_wrapper_init(a6xx_gpu, node);
>>> else
>>> ret = a6xx_gmu_init(a6xx_gpu, node);
>>> - of_node_put(node);
>>> if (ret) {
>>> a6xx_destroy(&(a6xx_gpu->base.base));
>>> return ERR_PTR(ret);
>>>
>>> ---
>>> base-commit: a0c666c25aeefd16f4b088c6549a6fb6b65a8a1d
>>> change-id: 20260123-a6xx_gpu-cbc095dbe423
>>>
>>> Best regards,
>>> --
>>> Felix Gu <ustc.gu@gmail.com>
>>>
>>
>> --
>> With best wishes
>> Dmitry
--
With best wishes
Dmitry
next prev parent reply other threads:[~2026-01-23 18:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 16:37 Felix Gu
2026-01-23 17:58 ` Dmitry Baryshkov
2026-01-23 18:21 ` Felix Gu
2026-01-23 18:23 ` Dmitry Baryshkov [this message]
2026-01-23 19:03 ` Felix Gu
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=e62971cd-ed56-46a3-ab47-46f3523ceeff@oss.qualcomm.com \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=akhilpo@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
--cc=ustc.gu@gmail.com \
/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®