Re: [PATCH] drivers/clk: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

[email protected]
Newsgroups org.kernel.vger.linux-clk
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Clock references obtained via `of_clk_get_by_name()` are leaked on the successful probe path.
- [Low] Missing named initializers for struct i2c_device_id array elements.
--

--- Patch [1]: [PATCH] drivers/clk: Convert to DEFINE_SIMPLE_DEV_PM_OPS() ---
commit 905f2dc2a103be650ab5a8a95761cebf0202b40a
Author: Triet Hoang <[email protected]>

drivers/clk: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Convert the deprecated SIMPLE_DEV_PM_OPS to DEFINE_SIMPLE_DEV_PM_OPS and
pm_sleep_ptr(). This lets us drop the maybe unused annotations from its
suspend and resume callbacks, and reduces kernel size in case CONFIG_PM or
CONFIG_PM_SLEEP is disabled.

> diff --git a/drivers/clk/clk-si521xx.c b/drivers/clk/clk-si521xx.c
> index ceadc07bcb6df..9336d08e80830 100644
> --- a/drivers/clk/clk-si521xx.c
> +++ b/drivers/clk/clk-si521xx.c
[ ... ]
> @@ -379,12 +379,12 @@ static const struct of_device_id clk_si521xx_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, clk_si521xx_of_match);
>  
> -static SIMPLE_DEV_PM_OPS(si521xx_pm_ops, si521xx_suspend, si521xx_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(si521xx_pm_ops, si521xx_suspend, si521xx_resume);
>  
>  static struct i2c_driver si521xx_driver = {
>  	.driver = {
>  		.name = "clk-si521xx",
> -		.pm	= &si521xx_pm_ops,
> +		.pm	= pm_sleep_ptr(&si521xx_pm_ops),
>  		.of_match_table = clk_si521xx_of_match,
>  	},
>  	.probe		= si521xx_probe,

[Severity: Low]
This is a pre-existing issue, but I noticed the si521xx_id array assigned
to the id_table near here uses a positional initializer for the
i2c_device_id name field. Does the I2C subsystem require named initializers
for i2c_device_id arrays?

> diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
> index 913fcc5675f19..bf2276981e01d 100644
> --- a/drivers/clk/clk-versaclock5.c
> +++ b/drivers/clk/clk-versaclock5.c
[ ... ]
> @@ -1335,12 +1335,12 @@ static const struct of_device_id clk_vc5_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, clk_vc5_of_match);
>  
> -static SIMPLE_DEV_PM_OPS(vc5_pm_ops, vc5_suspend, vc5_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(vc5_pm_ops, vc5_suspend, vc5_resume);
>  
>  static struct i2c_driver vc5_driver = {
>  	.driver = {
>  		.name = "vc5",
> -		.pm	= &vc5_pm_ops,
> +		.pm	= pm_sleep_ptr(&vc5_pm_ops),
>  		.of_match_table = clk_vc5_of_match,
>  	},
>  	.probe		= vc5_probe,

[Severity: Low]
This is also a pre-existing issue, but similar to the si521xx driver, the
vc5_id array uses a positional initializer. Should this be updated to use
a named initializer to match I2C subsystem guidelines?

> diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c
> index 5f64d93b2facf..9c8b17cb5e7c1 100644
> --- a/drivers/clk/samsung/clk-exynos-clkout.c
> +++ b/drivers/clk/samsung/clk-exynos-clkout.c
> @@ -214,7 +214,7 @@ static void exynos_clkout_remove(struct platform_device *pdev)

[Severity: High]
This is a pre-existing issue, but looking at exynos_clkout_probe() right
above this remove function, do we leak clock references on probe success?

It appears that exynos_clkout_probe() retrieves parent clock references
using of_clk_get_by_name() and stores them in a local parents array. While
clk_put() is correctly called in the err_clk_unreg path, the function
returns 0 on success without dropping the references. 

Could this permanently leak the references when the local array goes out of
scope, preventing the provider modules from ever being unloaded?

>  	iounmap(clkout->reg);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.