diff options
| author | William Theesfeld <william@theesfeld.net> | 2026-06-01 16:35:00 -0400 |
|---|---|---|
| committer | Brian Masney <bmasney@redhat.com> | 2026-06-29 13:21:09 -0400 |
| commit | d4d0d335e8d37c6c7e1c5664c7664288eca5a09b (patch) | |
| tree | bd45a6c2494109a2f24516a4387bd1f893e29d09 /include/linux/raid | |
| parent | ff29670735e0d9ac683529e316b8d4dcd09177ac (diff) | |
clk: zynq: handle kasprintf() failure in periph_clk registration
zynq_clk_register_periph_clk() ignores the return value of the two
kasprintf() calls used to build the mux and divider clock names, and
passes the resulting (possibly NULL) pointers straight into
clk_register_mux(), clk_register_divider() and clk_register_gate() as
the clock '"'name'"' argument. On allocation failure that name later
gets dereferenced by the clock framework (e.g. in debugfs name
formatting), causing a NULL-pointer dereference.
Check both kasprintf() returns. On failure unwind any allocated name
buffer and the spinlock, then fall through to the existing err label
which sets clks[] to ERR_PTR(-ENOMEM). Freeing the spinlock on the
error path is correct here because no clk_register_*() call has had
a chance to take ownership of it; the success path intentionally
hands it off to the registered clocks.
The neighbouring zynq_clk_register_fclk() in the same file already
uses this per-allocation goto-label cleanup pattern; this change
brings periph_clk into line with it.
Signed-off-by: William Theesfeld <william@theesfeld.net>
Reviewed-by: Brian Masney <bmasney@redhat.com>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Brian Masney <bmasney@redhat.com>
Diffstat (limited to 'include/linux/raid')
0 files changed, 0 insertions, 0 deletions
