Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] The OF device node reference obtained from 
`for_each_child_of_node()` is leaked when assigning the OF node to the platform 
device.
--

commit 0b7f7e14c13b65be057bb0d2e9e1a4b953a99635
Author: Bartosz Golaszewski <[email protected]>

i2c: pxa-pci: use platform_device_set_of_node()

This patch updates the i2c-pxa-pci driver to use the new
platform_device_set_of_node() helper for dynamically allocated platform
devices. It replaces the direct assignment of the OF node pointer ahead of
upcoming reference counting reworks in the driver core.

> diff --git a/drivers/i2c/busses/i2c-pxa-pci.c 
> b/drivers/i2c/busses/i2c-pxa-pci.c
> index dbd542300f800..92a0647f08c69 100644
> --- a/drivers/i2c/busses/i2c-pxa-pci.c
> +++ b/drivers/i2c/busses/i2c-pxa-pci.c
> @@ -76,7 +76,8 @@ static struct platform_device *add_i2c_device(struct 
> pci_dev *dev, int bar)
>               goto out;
>       }
>       pdev->dev.parent = &dev->dev;
> -     pdev->dev.of_node = child;
> +
> +     platform_device_set_of_node(pdev, child);

[Severity: Medium]
Does this change introduce an OF node reference leak?

Earlier in add_i2c_device(), the child node is acquired using a
for_each_child_of_node() loop that exits via break. This leaves the child
variable with an incremented reference count.

Before this patch, the direct assignment implicitly transferred this
reference to the platform device. The new platform_device_set_of_node()
helper takes its own additional reference internally when setting the fwnode.
Since the caller's original reference is never explicitly dropped after
this helper is called, it seems this will leak the OF node reference on both
the success and error paths. Should there be an of_node_put(child) after
calling the helper?

>  
>       ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
>       if (ret)

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=8

Reply via email to