Commit 8819e19b authored by Duoming Zhou's avatar Duoming Zhou Committed by Yu Liao
Browse files

clk: zynq: Prevent null pointer dereference caused by kmalloc failure

mainline inclusion
from mainline-v6.9-rc1
commit 7938e9ce39d6779d2f85d822cc930f73420e54a6
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9L9NB
CVE: CVE-2024-27037

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=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: 0ee52b15 ("clk: zynq: Add clock controller driver")
Suggested-by: default avatarMichal Simek <michal.simek@amd.com>
Suggested-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/20240301084437.16084-1-duoming@zju.edu.cn


Acked-by: default avatarMichal Simek <michal.simek@amd.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Conflicts:
	drivers/clk/zynq/clkc.c
[The conflicts were caused by not merged bf2244ba("clk: zynq:
clkc: Remove various instances of an unused variable 'clk'")]
Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
parent 7d91c9c7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment