Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49c1e32e authored by Yang Yingliang's avatar Yang Yingliang Committed by Greg Kroah-Hartman
Browse files

mfd: davinci_voicecodec: Fix possible null-ptr-deref davinci_vc_probe()



[ Upstream commit 311242c7703df0da14c206260b7e855f69cb0264 ]

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: b5e29aa8 ("mfd: davinci_voicecodec: Remove pointless #include")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220426030857.3539336-1-yangyingliang@huawei.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent bcb6c4c5
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -46,14 +46,12 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
	}
	}
	clk_enable(davinci_vc->clk);
	clk_enable(davinci_vc->clk);


	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	davinci_vc->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);

	fifo_base = (dma_addr_t)res->start;
	davinci_vc->base = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(davinci_vc->base)) {
	if (IS_ERR(davinci_vc->base)) {
		ret = PTR_ERR(davinci_vc->base);
		ret = PTR_ERR(davinci_vc->base);
		goto fail;
		goto fail;
	}
	}
	fifo_base = (dma_addr_t)res->start;


	davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev,
	davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev,
						   davinci_vc->base,
						   davinci_vc->base,