mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
clk/x86: pmc_atom: add kasprintf return value check
The kasprintf() function returns NULL on memory allocation failure, but
the code in plt_clk_register() was not checking this return value. If
kasprintf fails, init.name would be NULL and could cause NULL pointer
dereference when clkdev_hw_create() uses it.
Add proper error checking for the kasprintf() return value and return
ERR_PTR(-ENOMEM) on failure.
Fixes: 1141d9d081 ("clk: x86: Add Atom PMC platform clocks")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Reviewed-by: Brian Masney <bmasney@redhat.com>
Signed-off-by: Brian Masney <bmasney@redhat.com>
This commit is contained in:
parent
2a97ca25f7
commit
18e9d14cba
|
|
@ -160,6 +160,9 @@ static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,
|
|||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
init.name = kasprintf(GFP_KERNEL, "%s_%d", PLT_CLK_NAME_BASE, id);
|
||||
if (!init.name)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
init.ops = &plt_clk_ops;
|
||||
init.flags = 0;
|
||||
init.parent_names = parent_names;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user