Message ID | 20220421134308.2885094-1-yangyingliang@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource() | expand |
On 4/21/22 8:43 AM, Yang Yingliang wrote: > 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>
Dne sobota, 23. april 2022 ob 21:45:05 CEST je Samuel Holland napisal(a): > On 4/21/22 8:43 AM, Yang Yingliang wrote: > > 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> > > Applied to sunxi/clk-fixes-for-5.18, thanks! Best regards, Jernej
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);
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> --- drivers/clk/sunxi/clk-sun9i-mmc.c | 2 ++ 1 file changed, 2 insertions(+)