Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] Replacing direct assignment of `pdev->dev.of_node` with 
`platform_device_set_of_node()` introduces an OF node reference leak.
--

commit 1020448923f472d3e1acfa19d1b3b2b19a08078e
Author: Bartosz Golaszewski <[email protected]>

i2c: pxa-pci: use platform_device_set_of_node()

This commit encapsulates the assignment of the OF node for dynamically
allocated platform devices by replacing direct assignment with the
platform_device_set_of_node() helper. This change prepares the driver
for an upcoming rework of the reference counting logic for platform devices.

> 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 cause an OF node reference leak in add_i2c_device()?

The for_each_child_of_node() loop earlier in this function acquires a
reference to the matched child node. Before this patch, the direct assignment
transferred ownership of that reference to the platform device.

Because platform_device_set_of_node() explicitly acquires its own additional
reference internally, the original reference from the loop iterator appears to
be left unreleased. 

Is an of_node_put(child) needed after this helper call to balance the
reference count?

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

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

Reply via email to