提交 f58ca215 编写于 作者: Y Yang Yingliang 提交者: Jernej Skrabec

clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource()

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Fixes: 7a6fca87 ("clk: sunxi: Add driver for A80 MMC config clocks/resets")
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NSamuel Holland <samuel@sholland.org>
Signed-off-by: NJernej Skrabec <jernej.skrabec@gmail.com>
Link: https://lore.kernel.org/r/20220421134308.2885094-1-yangyingliang@huawei.com
上级 b4f3d5f0
...@@ -109,6 +109,8 @@ static int sun9i_a80_mmc_config_clk_probe(struct platform_device *pdev) ...@@ -109,6 +109,8 @@ static int sun9i_a80_mmc_config_clk_probe(struct platform_device *pdev)
spin_lock_init(&data->lock); spin_lock_init(&data->lock);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r)
return -EINVAL;
/* one clock/reset pair per word */ /* one clock/reset pair per word */
count = DIV_ROUND_UP((resource_size(r)), SUN9I_MMC_WIDTH); count = DIV_ROUND_UP((resource_size(r)), SUN9I_MMC_WIDTH);
data->membase = devm_ioremap_resource(&pdev->dev, r); data->membase = devm_ioremap_resource(&pdev->dev, r);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册