[PATCH v7 06/13] clk: zte: Add Clock registration infrastructure
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Jul 16 15:26:16 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] In `zx_clk_common_probe()`, the error path for `data->init(map)` incorrectly returns `PTR_ERR(clk)` instead of propagating the actual error code `res`.
--
--- Patch [6]: [PATCH v7 06/13] clk: zte: Add Clock registration infrastructure ---
commit 377a6af7769b840d87a85b32af3001fd5f4431dd
Author: Stefan Dösinger <stefandoesinger at gmail.com>
clk: zte: Add Clock registration infrastructure
This commit adds the common clock registration infrastructure for ZTE SoCs.
It includes support for registering PLLs, muxes, dividers, and gates using
regmap, and introduces a common probe function to initialize them.
> diff --git a/drivers/clk/zte/clk-zx.c b/drivers/clk/zte/clk-zx.c
> new file mode 100644
> index 0000000000000..db4fad2b4b056
> --- /dev/null
> +++ b/drivers/clk/zte/clk-zx.c
[ ... ]
> @@ -0,0 +1,155 @@
[ ... ]
> +int zx_clk_common_probe(struct device *dev, struct device_node *of_node,
> + const struct zx_clk_data *data)
> +{
[ ... ]
> + if (data->init) {
> + res = data->init(map);
> + if (res)
> + return dev_err_probe(dev, PTR_ERR(clk), "Controller init failure\n");
[Severity: High]
Does this code pass the wrong error code to dev_err_probe() in the
zx_clk_common_probe() error path?
When data->init(map) fails, it returns a non-zero error code into res.
However, the error handling block incorrectly evaluates and returns
PTR_ERR(clk).
Since clk is merely an iteration variable from the preceding loops, it could
be completely uninitialized if num_inputs_enable and num_inputs are 0, which
might trick the driver core into assuming the probe succeeded despite
initialization failing.
If the loops did execute successfully, clk holds a valid pointer, and
PTR_ERR(clk) will return a random large number depending on the pointer's
memory address, resulting in a meaningless error code.
Should this return res instead of PTR_ERR(clk)?
> + }
> +
> + res = zx_clk_register_plls(dev, map, data->plls, data->num_plls);
> + if (res)
> + return res;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260717-zx29clk-v7-0-408411cfcf36@gmail.com?part=6
More information about the linux-phy
mailing list