]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:56 +0000 (18:19 -0400)
commit0801c893fd48cdba66a3c8f44c3fe43cc67d3b85
treeb3344582ddd76b0146863e014338ddb9397efc12
parenta5d9b1aa61b401867b9066d54086b3e4ee91f8ed
clk: zynq: Prevent null pointer dereference caused by kmalloc failure

[ Upstream commit 7938e9ce39d6779d2f85d822cc930f73420e54a6 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clk/zynq/clkc.c