ASoC: amd: Add error checking to probe function
authorGuenter Roeck <[email protected]>
Tue, 21 Nov 2017 04:27:56 +0000 (20:27 -0800)
committerMark Brown <[email protected]>
Mon, 27 Nov 2017 16:30:54 +0000 (16:30 +0000)
The acp_audio_dma does not perform sufficient error checking in its probe
function. This can result in crashes if a critical error path is
encountered.

Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver")
Cc: Alex Deucher <[email protected]>
Cc: Dominik Behr <[email protected]>
Cc: Daniel Kurtz <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
Reviewed-by: Alex Deucher <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
sound/soc/amd/acp-pcm-dma.c

index 9f521a55d610186ae78d433909edd26c8dc7035f..b5e41df6bb3a895f10a90756fab0e54954a685d7 100644 (file)
@@ -1051,6 +1051,11 @@ static int acp_audio_probe(struct platform_device *pdev)
        struct resource *res;
        const u32 *pdata = pdev->dev.platform_data;
 
+       if (!pdata) {
+               dev_err(&pdev->dev, "Missing platform data\n");
+               return -ENODEV;
+       }
+
        audio_drv_data = devm_kzalloc(&pdev->dev, sizeof(struct audio_drv_data),
                                        GFP_KERNEL);
        if (audio_drv_data == NULL)
@@ -1058,6 +1063,8 @@ static int acp_audio_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        audio_drv_data->acp_mmio = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(audio_drv_data->acp_mmio))
+               return PTR_ERR(audio_drv_data->acp_mmio);
 
        /* The following members gets populated in device 'open'
         * function. Till then interrupts are disabled in 'acp_init'