clk: zynq: Prevent null pointer dereference caused by kmalloc failure
authorDuoming Zhou <duoming@zju.edu.cn>
Fri, 1 Mar 2024 08:44:37 +0000 (16:44 +0800)
committerStephen Boyd <sboyd@kernel.org>
Sat, 9 Mar 2024 01:15:20 +0000 (17:15 -0800)
commit7938e9ce39d6779d2f85d822cc930f73420e54a6
tree80f7a3ad4acb25ccce65ad8f7810c66e51d011bc
parentc1ab111e62496d8c1232da767c2bc5cdc76596e5
clk: zynq: Prevent null pointer dereference caused by kmalloc failure

The kmalloc() in zynq_clk_setup() will return null if the
physical memory has run out. As a result, if we use snprintf()
to write data to the null address, the null pointer dereference
bug will happen.

This patch uses a stack variable to replace the kmalloc().

Fixes: 0ee52b157b8e ("clk: zynq: Add clock controller driver")
Suggested-by: Michal Simek <michal.simek@amd.com>
Suggested-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/20240301084437.16084-1-duoming@zju.edu.cn
Acked-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/zynq/clkc.c