Re: [PATCH 6/8] mfd: tps6586: use platform_device_set_fwnode()

[email protected] Tue, 21 Jul 2026 09:26:02 +0000
Newsgroups dev.linux.lists.mfd,dev.linux.lists.imx
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Low] The commit message uses non-standard capitalization for the description, violating MFD subsystem prefix rules.

Pre-existing issues:
- [High] Manual assignment of `pdev->dev.platform_data` bypasses `platform_device_add_data()`, causing a bad free and kernel panic during device release.
--

--- Patch [6]: [PATCH 6/8] mfd: tps6586: use platform_device_set_fwnode() ---
commit 0c67148d3505d89af495783abc48f5f8ff3075d3
Author: Bartosz Golaszewski <[email protected]>

mfd: tps6586: use platform_device_set_fwnode()

This commit updates the tps6586 driver to prefer the higher-level
platform_device_set_fwnode() over the OF-specific
platform_device_set_of_node() for dynamically allocated platform devices.

> mfd: tps6586: use platform_device_set_fwnode()

[Severity: Low]
This isn't a bug, but should the description after the subsystem prefix
be capitalized?

The MFD subsystem guidelines dictate always capitalizing the description
after the subsystem prefix for MFD, LED, and Backlight subsystems.

> diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
> --- a/drivers/mfd/tps6586x.c
> +++ b/drivers/mfd/tps6586x.c

[ ... ]

> @@ -397,7 +397,7 @@ static int tps6586x_add_subdevs(struct tps6586x *tps6586x,
>  
>  		pdev->dev.parent = tps6586x->dev;
>  		pdev->dev.platform_data = subdev->platform_data;

[Severity: High]
This is a pre-existing issue, but does assigning the platform_data pointer
directly like this cause a bad free and kernel panic during device release?

When platform_device_release() is called, either due to a failure in
platform_device_add() or when the device is unregistered later, it
unconditionally calls kfree() on the platform_data pointer.

Since subdev->platform_data is typically statically allocated by board files
rather than dynamically allocated by the platform bus, bypassing the proper
duplication handled by platform_device_add_data() can lead to a crash.

> -		platform_device_set_of_node(pdev, subdev->of_node);
> +		platform_device_set_fwnode(pdev, of_fwnode_handle(subdev->of_node));
>  
>  		ret = platform_device_add(pdev);
>  		if (ret) {

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/20260720-pdev-set-fwnode-instead-of-of-node-v1-0-2dee93f42c54@oss.qualcomm.com?part=6