public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource()
@ 2022-04-21 13:43 Yang Yingliang
  2022-04-23 19:45 ` Samuel Holland
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Yingliang @ 2022-04-21 13:43 UTC (permalink / raw)
  To: linux-kernel, linux-sunxi, linux-arm-kernel, linux-clk; +Cc: wens, maxime

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(+)

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);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource()
  2022-04-21 13:43 [PATCH] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource() Yang Yingliang
@ 2022-04-23 19:45 ` Samuel Holland
  2022-04-25 17:59   ` Jernej Škrabec
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Holland @ 2022-04-23 19:45 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, linux-sunxi, linux-arm-kernel,
	linux-clk
  Cc: wens, maxime

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>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: [PATCH] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource()
  2022-04-23 19:45 ` Samuel Holland
@ 2022-04-25 17:59   ` Jernej Škrabec
  0 siblings, 0 replies; 3+ messages in thread
From: Jernej Škrabec @ 2022-04-25 17:59 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, linux-sunxi, linux-arm-kernel,
	linux-clk, Samuel Holland
  Cc: wens, maxime

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



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-25 18:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-21 13:43 [PATCH] clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource() Yang Yingliang
2022-04-23 19:45 ` Samuel Holland
2022-04-25 17:59   ` Jernej Škrabec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox