linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] media: mdp3: Fix resource leak in a for_each_child_of_node() loop
       [not found] <20230719100137.41161-1-luhongfei@vivo.com>
@ 2023-07-19 11:27 ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-07-19 11:27 UTC (permalink / raw)
  To: 路红飞,
	Mauro Carvalho Chehab, Matthias Brugger, Hans Verkuil, Moudy Ho,
	Ping-Hsun Wu, Arnd Bergmann, Deepak R Varma, Sun Ke, linux-media,
	linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: opensource.kernel

Il 19/07/23 12:01, 路红飞 ha scritto:
> for_each_child_of_node should have of_node_put()
> in error path avoid resource leaks.
> 
> Signed-off-by: Lu Hongfei <luhongfei@vivo.com>

That's still HTML; please avoid Cc'ing a bunch of people if you're testing
your email sendout.

Please test internally and once working send it again.

Btw, the code looks good... but I can't give you a R-b because of HTML format.

Thanks,
Angelo

> ---
> 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;
>   		}
>   



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] media: mdp3: Fix resource leak in a for_each_child_of_node() loop
       [not found]   ` <30bf6cc7-615b-52c5-0c23-f8b4be890e5e@vivo.com>
@ 2023-07-20 12:47     ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-07-20 12:47 UTC (permalink / raw)
  To: Lu Hongfei, Mauro Carvalho Chehab, Matthias Brugger,
	Hans Verkuil, Moudy Ho, Arnd Bergmann, Sun Ke, Deepak R Varma,
	linux-media, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: opensource.kernel

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@collabora.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@vivo.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@collabora.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] media: mdp3: Fix resource leak in a for_each_child_of_node() loop
       [not found] <20230720062248.37906-1-luhongfei@vivo.com>
@ 2023-07-20  7:51 ` AngeloGioacchino Del Regno
       [not found]   ` <30bf6cc7-615b-52c5-0c23-f8b4be890e5e@vivo.com>
  0 siblings, 1 reply; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-07-20  7:51 UTC (permalink / raw)
  To: Lu Hongfei, Mauro Carvalho Chehab, Matthias Brugger,
	Hans Verkuil, Moudy Ho, Arnd Bergmann, Sun Ke, Deepak R Varma,
	linux-media, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: opensource.kernel

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@vivo.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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-20 12:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230719100137.41161-1-luhongfei@vivo.com>
2023-07-19 11:27 ` [PATCH v2] media: mdp3: Fix resource leak in a for_each_child_of_node() loop AngeloGioacchino Del Regno
     [not found] <20230720062248.37906-1-luhongfei@vivo.com>
2023-07-20  7:51 ` AngeloGioacchino Del Regno
     [not found]   ` <30bf6cc7-615b-52c5-0c23-f8b4be890e5e@vivo.com>
2023-07-20 12:47     ` AngeloGioacchino Del Regno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).