lkml.org 
[lkml]   [2022]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem
On Fri 07 Jan 01:31 CST 2022, Miaoqian Lin wrote:

> The reference taken by 'of_find_device_by_node()' must be released when
> not needed anymore.
> Add the corresponding 'put_device()' in the error handling path.
>
> Fixes: 01f937ffc468 ("soc: qcom: ocmem: don't return NULL in of_get_ocmem")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Your patch solves the particular problem, so I'm applying it.

But it seems that we never release pdev in the case of successfully
return the ocmem object either... So there's more to improve here.

Regards,
Bjorn

> ---
> drivers/soc/qcom/ocmem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/soc/qcom/ocmem.c b/drivers/soc/qcom/ocmem.c
> index d2dacbbaafbd..97fd24c178f8 100644
> --- a/drivers/soc/qcom/ocmem.c
> +++ b/drivers/soc/qcom/ocmem.c
> @@ -206,6 +206,7 @@ struct ocmem *of_get_ocmem(struct device *dev)
> ocmem = platform_get_drvdata(pdev);
> if (!ocmem) {
> dev_err(dev, "Cannot get ocmem\n");
> + put_device(&pdev->dev);
> return ERR_PTR(-ENODEV);
> }
> return ocmem;
> --
> 2.17.1
>

\
 
 \ /
  Last update: 2022-01-31 23:15    [W:0.074 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site