All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem
@ 2022-01-07  7:31 Miaoqian Lin
  2022-01-31 22:14 ` Bjorn Andersson
  2022-02-04 18:35 ` (subset) " Bjorn Andersson
  0 siblings, 2 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-01-07  7:31 UTC (permalink / raw)
  Cc: linmq006, Andy Gross, Bjorn Andersson, Luca Weiss, Brian Masney,
	linux-arm-msm, linux-kernel

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


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

* Re: [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem
  2022-01-07  7:31 [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem Miaoqian Lin
@ 2022-01-31 22:14 ` Bjorn Andersson
  2022-03-01  6:58   ` Miaoqian Lin
  2022-02-04 18:35 ` (subset) " Bjorn Andersson
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Andersson @ 2022-01-31 22:14 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Andy Gross, Luca Weiss, Brian Masney, linux-arm-msm, linux-kernel

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
> 

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

* Re: (subset) [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem
  2022-01-07  7:31 [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem Miaoqian Lin
  2022-01-31 22:14 ` Bjorn Andersson
@ 2022-02-04 18:35 ` Bjorn Andersson
  1 sibling, 0 replies; 4+ messages in thread
From: Bjorn Andersson @ 2022-02-04 18:35 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Luca Weiss, linux-kernel, linux-arm-msm, Brian Masney, Andy Gross

On Fri, 7 Jan 2022 07:31:26 +0000, 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.
> 
> 

Applied, thanks!

[1/1] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem
      commit: 0ff027027e05a866491bbb53494f0e2a61354c85

Best regards,
-- 
Bjorn Andersson <bjorn.andersson@linaro.org>

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

* Re: [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem
  2022-01-31 22:14 ` Bjorn Andersson
@ 2022-03-01  6:58   ` Miaoqian Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-03-01  6:58 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Luca Weiss, Brian Masney, linux-arm-msm, linux-kernel

Hi, Andersson:

> 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.
> 
Thanks for your time. Should I submit another patch to release pdev 
in the regular path?

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

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

end of thread, other threads:[~2022-03-01  6:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  7:31 [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem Miaoqian Lin
2022-01-31 22:14 ` Bjorn Andersson
2022-03-01  6:58   ` Miaoqian Lin
2022-02-04 18:35 ` (subset) " Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.