linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: qcom: Put child node before return
@ 2021-01-21 11:49 Pan Bian
  2021-01-22 22:47 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Pan Bian @ 2021-01-21 11:49 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Linus Walleij
  Cc: linux-arm-msm, linux-kernel, Pan Bian

Put child node before return to fix potential reference count leak.
Generally, the reference count of child is incremented and decremented
automatically in the macro for_each_available_child_of_node() and should
be decremented manually if the loop is broken in loop body.

Fixes: 335a12754808 ("bus: qcom: add EBI2 driver")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/bus/qcom-ebi2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/qcom-ebi2.c b/drivers/bus/qcom-ebi2.c
index 03ddcf426887..0b8f53a688b8 100644
--- a/drivers/bus/qcom-ebi2.c
+++ b/drivers/bus/qcom-ebi2.c
@@ -353,8 +353,10 @@ static int qcom_ebi2_probe(struct platform_device *pdev)
 
 		/* Figure out the chipselect */
 		ret = of_property_read_u32(child, "reg", &csindex);
-		if (ret)
+		if (ret) {
+			of_node_put(child);
 			return ret;
+		}
 
 		if (csindex > 5) {
 			dev_err(dev,
-- 
2.17.1



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

* Re: [PATCH] bus: qcom: Put child node before return
  2021-01-21 11:49 [PATCH] bus: qcom: Put child node before return Pan Bian
@ 2021-01-22 22:47 ` Linus Walleij
  2021-01-22 23:19   ` Bjorn Andersson
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2021-01-22 22:47 UTC (permalink / raw)
  To: Pan Bian; +Cc: Andy Gross, Bjorn Andersson, MSM, linux-kernel

On Thu, Jan 21, 2021 at 12:49 PM Pan Bian <bianpan2016@163.com> wrote:

> Put child node before return to fix potential reference count leak.
> Generally, the reference count of child is incremented and decremented
> automatically in the macro for_each_available_child_of_node() and should
> be decremented manually if the loop is broken in loop body.
>
> Fixes: 335a12754808 ("bus: qcom: add EBI2 driver")
> Signed-off-by: Pan Bian <bianpan2016@163.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Please submit this patch for inclusion through the ARM SoC tree.

Yours,
Linus Walleij

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

* Re: [PATCH] bus: qcom: Put child node before return
  2021-01-22 22:47 ` Linus Walleij
@ 2021-01-22 23:19   ` Bjorn Andersson
  2021-01-23 23:00     ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Bjorn Andersson @ 2021-01-22 23:19 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Pan Bian, Andy Gross, MSM, linux-kernel

On Fri 22 Jan 16:47 CST 2021, Linus Walleij wrote:

> On Thu, Jan 21, 2021 at 12:49 PM Pan Bian <bianpan2016@163.com> wrote:
> 
> > Put child node before return to fix potential reference count leak.
> > Generally, the reference count of child is incremented and decremented
> > automatically in the macro for_each_available_child_of_node() and should
> > be decremented manually if the loop is broken in loop body.
> >
> > Fixes: 335a12754808 ("bus: qcom: add EBI2 driver")
> > Signed-off-by: Pan Bian <bianpan2016@163.com>
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
> Please submit this patch for inclusion through the ARM SoC tree.
> 

Any objections to me picking it in the Qualcomm tree? Or that's what you
indirectly meant?

Regards,
Bjorn

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

* Re: [PATCH] bus: qcom: Put child node before return
  2021-01-22 23:19   ` Bjorn Andersson
@ 2021-01-23 23:00     ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2021-01-23 23:00 UTC (permalink / raw)
  To: Bjorn Andersson; +Cc: Pan Bian, Andy Gross, MSM, linux-kernel

On Sat, Jan 23, 2021 at 12:19 AM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> On Fri 22 Jan 16:47 CST 2021, Linus Walleij wrote:
>
> > On Thu, Jan 21, 2021 at 12:49 PM Pan Bian <bianpan2016@163.com> wrote:
> >
> > > Put child node before return to fix potential reference count leak.
> > > Generally, the reference count of child is incremented and decremented
> > > automatically in the macro for_each_available_child_of_node() and should
> > > be decremented manually if the loop is broken in loop body.
> > >
> > > Fixes: 335a12754808 ("bus: qcom: add EBI2 driver")
> > > Signed-off-by: Pan Bian <bianpan2016@163.com>
> >
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> >
> > Please submit this patch for inclusion through the ARM SoC tree.
> >
>
> Any objections to me picking it in the Qualcomm tree? Or that's what you
> indirectly meant?

Kind-of-sort-of :D

Apply it to the Qualcomm tree!

Yours,
Linus Walleij

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

end of thread, other threads:[~2021-01-23 23:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 11:49 [PATCH] bus: qcom: Put child node before return Pan Bian
2021-01-22 22:47 ` Linus Walleij
2021-01-22 23:19   ` Bjorn Andersson
2021-01-23 23:00     ` Linus Walleij

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