Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] OF node reference leak for dynamically allocated platform devices due to incomplete tree-wide conversion. --
commit 50bc78e1d223d4a9addf4cc0c3c1d384a104d5a6 Author: Bartosz Golaszewski <[email protected]> driver core: platform: count references to all kinds of firmware nodes When using platform_device_register_full(), we currently only increase the reference count of the OF node associated with a platform device. We symmetrically decrease it in platform_device_release(). With all users in tree now converted to using provided platform device helpers for assigning OF and firmware nodes, we can now switch to counting references of all kinds of firmware nodes. > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index 9357942d0c79b..a71015f1d9153 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -599,7 +599,7 @@ static void platform_device_release(struct device *dev) > struct platform_object *pa = container_of(dev, struct platform_object, > pdev.dev); > > - of_node_put(pa->pdev.dev.of_node); > + fwnode_handle_put(pa->pdev.dev.fwnode); [Severity: High] Does this code leak the device_node for drivers that haven't been fully converted to the platform device helpers? The commit message mentions that all in-tree users are converted, but there appear to be some unconverted drivers still using device_set_of_node_from_dev on dynamically allocated platform devices. For example, in drivers/usb/host/fsl-mph-dr-of.c:fsl_usb2_device_register(): device_set_of_node_from_dev(&pdev->dev, &ofdev->dev); And in drivers/usb/musb/musb_dsps.c:dsps_create_musb_pdev(): device_set_of_node_from_dev(&musb->dev, &parent->dev); Since device_set_of_node_from_dev() sets and increments dev->of_node without setting dev->fwnode, won't fwnode_handle_put(NULL) do nothing and permanently leak the OF node reference when these devices are released? -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=20
