[<prev] [next>] [day] [month] [year] [list]
Message-ID: <c2b8d1dc-fdbe-5ea6-89d6-6b1113fc3a55@collabora.com>
Date: Thu, 20 Jul 2023 14:47:43 +0200
From: AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
To: Lu Hongfei <luhongfei@...o.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Moudy Ho <moudy.ho@...iatek.com>,
Arnd Bergmann <arnd@...db.de>, Sun Ke <sunke32@...wei.com>,
Deepak R Varma <drv@...lo.com>,
"linux-media@...r.kernel.org" <linux-media@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-mediatek@...ts.infradead.org"
<linux-mediatek@...ts.infradead.org>
Cc: "opensource.kernel" <opensource.kernel@...o.com>
Subject: Re: [PATCH v2] media: mdp3: Fix resource leak in a
for_each_child_of_node() loop
Il 20/07/23 14:19, Lu Hongfei ha scritto:
> On 2023/7/20 15:51, AngeloGioacchino Del Regno wrote:
>> [Some people who received this message don't often get email from
>> angelogioacchino.delregno@...labora.com. Learn why this is important
>> at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> Il 20/07/23 08:23, Lu Hongfei ha scritto:
>>> for_each_child_of_node should have of_node_put()
>>> in error path avoid resource leaks.
>>>
>>> Signed-off-by: Lu Hongfei <luhongfei@...o.com>
>>> ---
>>> Changelog:
>>> v1->v2:
>>> 1. Change the subject line of this patch to include driver name.
>>> 2. Remove the unneeded of_node_put.
>>>
>>> drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
>>> b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
>>> index a605e80c7dc3..40c4b79a5090 100644
>>> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
>>> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
>>> @@ -1135,6 +1135,7 @@ int mdp_comp_config(struct mdp_dev *mdp)
>>> comp = mdp_comp_create(mdp, node, id);
>>> if (IS_ERR(comp)) {
>>> ret = PTR_ERR(comp);
>>> + of_node_put(node);
>>> goto err_init_comps;
>>> }
>>>
>>
>> In case mdp_comp_sub_create() fails, we still want to decrease the
>> refcount
>> of `node`....
>>
>> ...so, just call of_node_put(node) just once, at the err_init_comps
>> label.
>>
>> err_init_comps:
>> mdp_comp_destroy(mdp);
>> of_node_put(node);
>> return ret;
>>
>> Regards,
>> Angelo
>
> mdp_comp_sub_create() executes after for_each_child_of_node loop ends.
>
> The for_each_child_of_node loop ended, node == NULL and there is nothing
> to put.
>
> So I don't think it's necessary to decrease the refcount of `node` again
> when
>
> mdp_comp_sub_create() fails.
>
> Or you could further explain the reason for doing so.
>
You're right. My bad.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Powered by blists - more mailing lists