[PATCH v21 2/4] regulator: p3h2x4x: Add driver for on-die regulators in NXP P3H2x4x i3c hub

sashiko-bot at kernel.org sashiko-bot at kernel.org
Thu Nov 12 04:56:22 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] regulator: p3h2x4x: OF node leak in p3h2x4x_regulator_probe()
--

commit 0c22fd7becea5c3dad0894cb83a63e3d27c04c45
Author: Aman Kumar Pandey <aman.kumarpandey at nxp.com>

regulator: p3h2x4x: Add driver for on-die regulators in NXP P3H2x4x i3c hub

This commit adds a regulator driver for the four on-die LDOs in the NXP
P3H2x4x I3C hub family, registered as a child of the MFD device.

> diff --git a/drivers/regulator/p3h2840_i3c_hub_regulator.c b/drivers/regulator/p3h2840_i3c_hub_regulator.c
> new file mode 100644
> index 0000000000000..244f2a4f70f38
> --- /dev/null
> +++ b/drivers/regulator/p3h2840_i3c_hub_regulator.c

[ ... ]

> +static int p3h2x4x_regulator_probe(struct platform_device *pdev)
> +{
> +	struct p3h2x4x *p3h2x4x = dev_get_drvdata(pdev->dev.parent);
> +	struct p3h2x4x_regulator_dev *p3h2x4x_regulator;
> +	struct regulator_config rcfg = { };
> +	struct device *dev = &pdev->dev;
> +	struct regulator_dev *rdev;
> +	int i;
> +
> +	p3h2x4x_regulator = devm_kzalloc(dev, sizeof(*p3h2x4x_regulator), GFP_KERNEL);
> +	if (!p3h2x4x_regulator)
> +		return -ENOMEM;
> +
> +	p3h2x4x_regulator->p3h2x4x = p3h2x4x;
> +	p3h2x4x_regulator->regmap = p3h2x4x->regmap;
> +
> +	platform_set_drvdata(pdev, p3h2x4x_regulator);
> +
> +	device_set_of_node_from_dev(dev, dev->parent);

[Severity: Medium]
Does calling device_set_of_node_from_dev() here leak a reference on
dev->parent->of_node when pdev is unregistered?

The MFD cell for p3h2x4x-regulator does not set of_compatible or swnode, so
mfd_add_device() allocates pdev with dev.fwnode set to NULL.
device_set_of_node_from_dev() takes a reference on dev->parent->of_node and
assigns dev->of_node without updating dev->fwnode, whereas
platform_device_release() drops the firmware node reference via
fwnode_handle_put(pa->pdev.dev.fwnode).

Using platform_device_set_of_node_from_dev(pdev, dev->parent) sets both
dev.of_node and dev.fwnode so platform_device_release() balances the
reference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112124437.3367252-1-lakshay.piplani@nxp.com?part=2



More information about the linux-i3c mailing list