Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:

Pre-existing issues:
- [High] Resource leak and duplicate registration failure due to misuse of 
`devm_` APIs against an external device in a component `.bind` callback.
--

--- Patch [1]: [PATCH 1/2] drm/sun4i: Make sure clk_init_data is fully 
initialized ---
commit c10328b2f0b88fab02ca03cdd9ba8cea5c03c556
Author: Geert Uytterhoeven <[email protected]>

drm/sun4i: Make sure clk_init_data is fully initialized

This commit zero-initializes the clk_init_data structure to ensure all
members are fully initialized. This prevents subtle issues when only
some mutually-exclusive members are set, especially under certain stack
initialization configs.

[ ... ]

> diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c 
> b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c
> index a4d31fe3abff1..bd0dba95421b3 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c
> @@ -143,7 +143,7 @@ static const struct clk_ops sun8i_phy_clk_ops = {
>  int sun8i_phy_clk_create(struct sun8i_hdmi_phy *phy, struct device *dev,
>                        bool second_parent)
>  {
> -     struct clk_init_data init;
> +     struct clk_init_data init = {};
>       struct sun8i_phy_clk *priv;
>       const char *parents[2];
>  

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential problem
with resource lifetimes in this function.

During the component bind phase, this code uses devm_kzalloc() and
devm_clk_register() against the external PHY platform device:

sun8i_phy_clk_create() {
    ...
        priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
    ...
        phy->clk_phy = devm_clk_register(dev, &priv->hw);
    ...
}

Because the devres group is attached to the external PHY device (`dev`) rather
than the component device, it escapes the component unbind cycle.

When the HDMI component is unbound and re-bound, sun8i_phy_clk_create() runs
again. Will this permanently leak the memory allocated for `priv`?

Furthermore, will devm_clk_register() fail with -EEXIST on the second bind
since the previous clock was never unregistered?

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

Reply via email to