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: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> 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:
Yu Liao <liaoyu15@huawei.com>
Loading
Please sign in to comment