* [PATCH] soc/tegra: fuse: fix possible null-ptr-deref in tegra_fuse_probe()
@ 2022-05-05 9:37 Yang Yingliang
0 siblings, 0 replies; only message in thread
From: Yang Yingliang @ 2022-05-05 9:37 UTC (permalink / raw)
To: linux-kernel, linux-tegra; +Cc: digetx, jonathanh, treding
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: 55a042b3f68f ("soc/tegra: fuse: Fix reading registers using DMA on Tegra20")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/soc/tegra/fuse/fuse-tegra.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index aa94fda282f4..e85a78a80c48 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -218,13 +218,12 @@ static int tegra_fuse_probe(struct platform_device *pdev)
return err;
/* take over the memory region from the early initialization */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- fuse->phys = res->start;
- fuse->base = devm_ioremap_resource(&pdev->dev, res);
+ fuse->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(fuse->base)) {
err = PTR_ERR(fuse->base);
return err;
}
+ fuse->phys = res->start;
fuse->clk = devm_clk_get(&pdev->dev, "fuse");
if (IS_ERR(fuse->clk)) {
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-05 9:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 9:37 [PATCH] soc/tegra: fuse: fix possible null-ptr-deref in tegra_fuse_probe() Yang Yingliang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).