summaryrefslogtreecommitdiffstats
path: root/drivers/clk/sunxi/clk-sun9i-mmc.c
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-04-21 15:43:08 +0200
committerJernej Skrabec <jernej.skrabec@gmail.com>2022-04-25 19:50:53 +0200
commitf58ca215cda1975f77b2b762903684a3c101bec9 (patch)
treeb916c11f5af2831bb5f292ba0d4414b1c6bca6d2 /drivers/clk/sunxi/clk-sun9i-mmc.c
parentclk: sunxi-ng: sun6i-rtc: Mark rtc-32k as critical (diff)
downloadlinux-f58ca215cda1975f77b2b762903684a3c101bec9.tar.xz
linux-f58ca215cda1975f77b2b762903684a3c101bec9.zip
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: 7a6fca879f59 ("clk: sunxi: Add driver for A80 MMC config clocks/resets") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Samuel Holland <samuel@sholland.org> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> Link: https://lore.kernel.org/r/20220421134308.2885094-1-yangyingliang@huawei.com
Diffstat (limited to 'drivers/clk/sunxi/clk-sun9i-mmc.c')
-rw-r--r--drivers/clk/sunxi/clk-sun9i-mmc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/clk/sunxi/clk-sun9i-mmc.c b/drivers/clk/sunxi/clk-sun9i-mmc.c
index 542b31d6e96d..636bcf2439ef 100644
--- a/drivers/clk/sunxi/clk-sun9i-mmc.c
+++ b/drivers/clk/sunxi/clk-sun9i-mmc.c
@@ -109,6 +109,8 @@ static int sun9i_a80_mmc_config_clk_probe(struct platform_device *pdev)
spin_lock_init(&data->lock);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!r)
+ return -EINVAL;
/* one clock/reset pair per word */
count = DIV_ROUND_UP((resource_size(r)), SUN9I_MMC_WIDTH);
data->membase = devm_ioremap_resource(&pdev->dev, r);