Skip to content

Commit 311242c

Browse files
Yang YingliangLee Jones
authored andcommitted
mfd: davinci_voicecodec: Fix possible null-ptr-deref davinci_vc_probe()
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: b5e29aa ("mfd: davinci_voicecodec: Remove pointless #include") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20220426030857.3539336-1-yangyingliang@huawei.com
1 parent eeb0a44 commit 311242c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/mfd/davinci_voicecodec.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
4646
}
4747
clk_enable(davinci_vc->clk);
4848

49-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
50-
51-
fifo_base = (dma_addr_t)res->start;
52-
davinci_vc->base = devm_ioremap_resource(&pdev->dev, res);
49+
davinci_vc->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
5350
if (IS_ERR(davinci_vc->base)) {
5451
ret = PTR_ERR(davinci_vc->base);
5552
goto fail;
5653
}
54+
fifo_base = (dma_addr_t)res->start;
5755

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

0 commit comments

Comments
 (0)