mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
clk: add uclass id check to clk_get_parent()
Check the uclass id in clk_get_parent() before casting dev->priv to struct clk *. This sanity check can be also found in some other places and should be enforced. Reviewed-by: Simon Glass <simon.glass@canonical.com> Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
This commit is contained in:
@@ -507,6 +507,10 @@ struct clk *clk_get_parent(struct clk *clk)
|
||||
pdev = dev_get_parent(clk->dev);
|
||||
if (!pdev)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (device_get_uclass_id(pdev) != UCLASS_CLK)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
pclk = dev_get_clk_ptr(pdev);
|
||||
if (!pclk)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
Reference in New Issue
Block a user