lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <305d7cf5f0a66efc01181f24d3a288d3.sboyd@kernel.org>
Date: Tue, 14 Jan 2025 10:30:16 -0800
From: Stephen Boyd <sboyd@...nel.org>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>, Joe Hattori <joe@...is.s.u-tokyo.ac.jp>, Konrad Dybcio <konradybcio@...il.com>, Konrad Dybcio <konradybcio@...nel.org>, Matthias Brugger <matthias.bgg@...il.com>, Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
Cc: Marijn Suijten <marijn.suijten@...ainline.org>, linux-kernel@...r.kernel.org, Bjorn Andersson <bjorn.andersson@....qualcomm.com>, Abel Vesa <abel.vesa@...aro.org>, Johan Hovold <johan+linaro@...nel.org>, linux-arm-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org, Konrad Dybcio <konrad.dybcio@....qualcomm.com>
Subject: Re: [PATCH v2] spmi: Fix controller->node != parent->node breakage

Quoting Konrad Dybcio (2025-01-13 14:12:28)
> 
> On 1/13/25 22:52, Stephen Boyd wrote:
> > Quoting Konrad Dybcio (2025-01-13 05:02:58)
> >>
> >> Make controller->node specifiable to both benefit from Joe's refcount
> >> improvements and un-break the aforementioned platforms.
> > 
> > How is it broken? I see spmi_pmic_arb_bus_init() calls
> > devm_spmi_controller_alloc() which sets the of_node to the parent device
> > and then spmi_pmic_arb_bus_init() overwrites that with
> > 'ctrl->dev.of_node = node' later on in the same function. That will
> > cause one more of_node_put() than is expected. I don't see that removed
> > in this patch though, so the leak is still there?
> > 
> >>
> >> Fixes: 821b07853e32 ("spmi: hisi-spmi-controller: manage the OF node reference in device initialization and cleanup")
> > 
> > I've dropped this patch from my queue. I don't know if we're really
> > doing anything better by managing the of_node lifetime in that function
> > vs. letting the callers assign the node they want and manage the
> > lifetime themselves. Maybe we don't need to do anything? Presumably the
> > parent device driver will unregister the controller anyway, so the
> > lifetime of the of_node will be ensured regardless. For subnodes like
> > qcom SPMI, the subnodes are child nodes of the parent device so they
> > won't be removed. If they are dynamic nodes, then the caller can manage
> > the lifetime.
> 
> Stephen, the wrong node gets assigned in the qcom driver with
> multi-master controllers, resulting in probe failures.
> 
> Since the introduction of the commit referenced in fixes,
> of_spmi_register_devices() sees the controller's subnodes
> (which describe each of the two masters) as slave devices
> - meaning no "real" devices ever get to probe
> 

Ok, I see that I was reading the already reverted state of the tree
where the 'ctrl->dev.of_node = node' assignment came back. So there's
nothing to do besides drop the patch in fixes, which I already did. We
can then apply this patch to drop the duplicate assignment as a cleanup
and to avoid a refcount bump on the of_node that isn't needed.

----8<---
diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c
index 3cafdf22c909..122140b97579 100644
--- a/drivers/spmi/hisi-spmi-controller.c
+++ b/drivers/spmi/hisi-spmi-controller.c
@@ -300,9 +300,6 @@ static int spmi_controller_probe(struct platform_device *pdev)
 
 	spin_lock_init(&spmi_controller->lock);
 
-	ctrl->dev.parent = pdev->dev.parent;
-	ctrl->dev.of_node = of_node_get(pdev->dev.of_node);
-
 	/* Callbacks */
 	ctrl->read_cmd = spmi_read_cmd;
 	ctrl->write_cmd = spmi_write_cmd;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ