* [PATCH] mfd: davinci_voicecodec: fix possible null-ptr-deref davinci_vc_probe()
@ 2022-04-26 3:08 Yang Yingliang
2022-05-23 13:53 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-04-26 3:08 UTC (permalink / raw)
To: linux-kernel; +Cc: lee.jones, nsekhar, arnd
It will cause null-ptr-deref when using 'res', if platform_get_resource()
returns NULL, so move using 'res' after devm_ioremap_resource() that
will check it to avoid null-ptr-deref.
And use devm_platform_get_and_ioremap_resource() to simplify code.
Fixes: b5e29aa880be ("mfd: davinci_voicecodec: Remove pointless #include")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/mfd/davinci_voicecodec.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c
index e5c8bc998eb4..965820481f1e 100644
--- a/drivers/mfd/davinci_voicecodec.c
+++ b/drivers/mfd/davinci_voicecodec.c
@@ -46,14 +46,12 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
}
clk_enable(davinci_vc->clk);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
- fifo_base = (dma_addr_t)res->start;
- davinci_vc->base = devm_ioremap_resource(&pdev->dev, res);
+ davinci_vc->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(davinci_vc->base)) {
ret = PTR_ERR(davinci_vc->base);
goto fail;
}
+ fifo_base = (dma_addr_t)res->start;
davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev,
davinci_vc->base,
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] mfd: davinci_voicecodec: fix possible null-ptr-deref davinci_vc_probe()
2022-04-26 3:08 [PATCH] mfd: davinci_voicecodec: fix possible null-ptr-deref davinci_vc_probe() Yang Yingliang
@ 2022-05-23 13:53 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2022-05-23 13:53 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-kernel, nsekhar, arnd
On Tue, 26 Apr 2022, Yang Yingliang wrote:
> It will cause null-ptr-deref when using 'res', if platform_get_resource()
> returns NULL, so move using 'res' after devm_ioremap_resource() that
> will check it to avoid null-ptr-deref.
> And use devm_platform_get_and_ioremap_resource() to simplify code.
>
> Fixes: b5e29aa880be ("mfd: davinci_voicecodec: Remove pointless #include")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/mfd/davinci_voicecodec.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
Applied, thanks.
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-23 13:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-26 3:08 [PATCH] mfd: davinci_voicecodec: fix possible null-ptr-deref davinci_vc_probe() Yang Yingliang
2022-05-23 13:53 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox