Skip to contentSkip to conversation

ASoC: amd: Add error checking to probe function

PATCH In review Guenter Roeck 5 participants 6 messages Nov 21, 2017 – Nov 27, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: amd: Add error checking to probe function

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]>

---
I didn't add an error check to acp_init() since I was not sure if its return value is ignored on purpose.

 sound/soc/amd/acp-pcm-dma.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/amd/acp-pcm-dma.c +7 -0
index 9f521a55d610..b5e41df6bb3a 100644
@@ -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'
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines

-----Original Message-----
From: Guenter Roeck [mailto:[email protected]] On Behalf Of Guenter Roeck
Sent: Monday, November 20, 2017 11:28 PM
To: Liam Girdwood
Cc: Mark Brown; Jaroslav Kysela; Takashi Iwai; [email protected]; [email protected]; Guenter Roeck; Deucher, Alexander; Dominik Behr; Daniel Kurtz
Subject: [PATCH] ASoC: amd: Add error checking to probe function

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.

Quoted 8 lines
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]>

---
I didn't add an error check to acp_init() since I was not sure if its return value is ignored on purpose.

Vijendar, Akshu can you comment?

The patch looks good to me.

Quoted 36 lines
 sound/soc/amd/acp-pcm-dma.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/amd/acp-pcm- renamed from sound/soc/amd/acp-pcm-dma.c +0 -0

dma.c
index 9f521a55d610..b5e41df6bb3a 100644

sound/soc/amd/acp-pcm-dma.c +5 -0
@@ -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),
sound/soc/amd/acp-pcm-dma.c +2 -0
 					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);
 
sound/soc/amd/acp-pcm-dma.c +0 -1
 	/* The following members gets populated in device 'open'
 	 * function. Till then interrupts are disabled in 'acp_init'
--

2.7.4

#2 lore raw
Quoted 23 lines · Alexander
Quoted 14 lines

-----Original Message-----
From: Guenter Roeck [mailto:[email protected]] On Behalf Of Guenter Roeck
Sent: Monday, November 20, 2017 11:28 PM
To: Liam Girdwood
Cc: Mark Brown; Jaroslav Kysela; Takashi Iwai; [email protected]; [email protected]; Guenter Roeck; Deucher, Alexander; Dominik Behr; Daniel Kurtz
Subject: [PATCH] ASoC: amd: Add error checking to probe function

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.

Quoted 8 lines
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]>

---
I didn't add an error check to acp_init() since I was not sure if its return value is ignored on purpose.

Quoted 1 line

Vijendar, Akshu can you comment?

This is also the case of missing error check.
acp_init will return error if either sw reset did not happen or clock did not get enabled. In both cases we should error out in probe.

Quoted 41 lines

The patch looks good to me.

Quoted 36 lines
  sound/soc/amd/acp-pcm-dma.c | 7 +++++++
  1 file changed, 7 insertions(+)
sound/soc/amd/acp-pcm- renamed from sound/soc/amd/acp-pcm-dma.c +0 -0

dma.c
index 9f521a55d610..b5e41df6bb3a 100644

sound/soc/amd/acp-pcm-dma.c +5 -0
@@ -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)

sound/soc/amd/acp-pcm-dma.c +2 -0
@@ -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'
--
2.7.4

#3 lore raw
Quoted 38 lines

-----Original Message-----
From: Agrawal, Akshu
Sent: Tuesday, November 21, 2017 1:15 AM
To: Deucher, Alexander; 'Guenter Roeck'; Liam Girdwood; Mukunda, Vijendar
Cc: Mark Brown; Jaroslav Kysela; Takashi Iwai; [email protected]; [email protected]; Dominik Behr; Daniel Kurtz
Subject: Re: [PATCH] ASoC: amd: Add error checking to probe function

Quoted 6 lines · Alexander
Quoted 6 lines

-----Original Message-----
From: Guenter Roeck [mailto:[email protected]] On Behalf Of Guenter Roeck
Sent: Monday, November 20, 2017 11:28 PM
To: Liam Girdwood
Cc: Mark Brown; Jaroslav Kysela; Takashi Iwai; alsa-devel@alsa-

project.org;

Quoted 1 line
Quoted 1 line

[email protected]; Guenter Roeck; Deucher, Alexander;

Dominik

Quoted 4 lines
Quoted 4 lines

Behr; Daniel Kurtz
Subject: [PATCH] ASoC: amd: Add error checking to probe function

The acp_audio_dma does not perform sufficient error checking in its

probe

Quoted 12 lines
Quoted 11 lines

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]>

---
I didn't add an error check to acp_init() since I was not sure if its return value is ignored on purpose.

Quoted 6 lines
Quoted 1 line

Vijendar, Akshu can you comment?

This is also the case of missing error check.
acp_init will return error if either sw reset did not happen or clock did not get enabled. In both cases we should error out in probe.

Can you send out a patch to enable that error checking?

Thanks,

Alex

Quoted 43 lines
Quoted 8 lines

The patch looks good to me.

Quoted 4 lines
  sound/soc/amd/acp-pcm-dma.c | 7 +++++++
  1 file changed, 7 insertions(+)
Quoted 6 lines

sound/soc/amd/acp-pcm-dma.c static int acp_audio_probe(struct

Quoted 6 lines
sound/soc/amd/acp-pcm- renamed from sound/soc/amd/acp-pcm-dma.c +0 -0

dma.c
index 9f521a55d610..b5e41df6bb3a 100644

sound/soc/amd/acp-pcm-dma.c +0 -0
@@ -1051,6 +1051,11 @@ static int acp_audio_probe(struct

platform_device

Quoted 4 lines
Quoted 4 lines
sound/soc/amd/acp-pcm-dma.c +0 -0
 *pdev)
  	struct resource *res;
  	const u32 *pdata = pdev->dev.platform_data;
 
Quoted 10 lines

sound/soc/amd/acp-pcm-dma.c static int acp_audio_probe(struct

Quoted 10 lines
sound/soc/amd/acp-pcm-dma.c +5 -0
+	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)

sound/soc/amd/acp-pcm-dma.c +0 -0
@@ -1058,6 +1063,8 @@ static int acp_audio_probe(struct

platform_device

Quoted 13 lines
Quoted 12 lines
sound/soc/amd/acp-pcm-dma.c +2 -0
 *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'
--
2.7.4

maintainer
#4 lore raw
Quoted 42 lines · Alexander
Quoted 37 lines

-----Original Message-----
From: Agrawal, Akshu
Sent: Tuesday, November 21, 2017 1:15 AM
To: Deucher, Alexander; 'Guenter Roeck'; Liam Girdwood; Mukunda, Vijendar
Cc: Mark Brown; Jaroslav Kysela; Takashi Iwai; [email protected]; [email protected]; Dominik Behr; Daniel Kurtz
Subject: Re: [PATCH] ASoC: amd: Add error checking to probe function

Quoted 6 lines · Alexander
Quoted 6 lines

-----Original Message-----
From: Guenter Roeck [mailto:[email protected]] On Behalf Of Guenter Roeck
Sent: Monday, November 20, 2017 11:28 PM
To: Liam Girdwood
Cc: Mark Brown; Jaroslav Kysela; Takashi Iwai; alsa-devel@alsa-

project.org;

Quoted 1 line
Quoted 1 line

[email protected]; Guenter Roeck; Deucher, Alexander;

Dominik

Quoted 4 lines
Quoted 4 lines

Behr; Daniel Kurtz
Subject: [PATCH] ASoC: amd: Add error checking to probe function

The acp_audio_dma does not perform sufficient error checking in its

probe

Quoted 11 lines
Quoted 11 lines

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]>

---
I didn't add an error check to acp_init() since I was not sure if its return value is ignored on purpose.

Quoted 5 lines
Quoted 1 line

Vijendar, Akshu can you comment?

This is also the case of missing error check.
acp_init will return error if either sw reset did not happen or clock did not get enabled. In both cases we should error out in probe.

Quoted 6 lines

Can you send out a patch to enable that error checking?

Thanks,

Alex

on top of this patch will add more error checks and submit a new patch

Quoted 40 lines
Quoted 40 lines
Quoted 6 lines

The patch looks good to me.

Quoted 3 lines
   sound/soc/amd/acp-pcm-dma.c | 7 +++++++
   1 file changed, 7 insertions(+)
Quoted 6 lines

sound/soc/amd/acp-pcm-dma.c static int acp_audio_probe(struct

Quoted 6 lines
sound/soc/amd/acp-pcm- renamed from sound/soc/amd/acp-pcm-dma.c +0 -0

dma.c
index 9f521a55d610..b5e41df6bb3a 100644

sound/soc/amd/acp-pcm-dma.c +0 -0
@@ -1051,6 +1051,11 @@ static int acp_audio_probe(struct

platform_device

Quoted 4 lines
Quoted 4 lines
sound/soc/amd/acp-pcm-dma.c +0 -0
 *pdev)
   	struct resource *res;
   	const u32 *pdata = pdev->dev.platform_data;
 
Quoted 10 lines

sound/soc/amd/acp-pcm-dma.c static int acp_audio_probe(struct

Quoted 10 lines
sound/soc/amd/acp-pcm-dma.c +5 -0
+	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)
sound/soc/amd/acp-pcm-dma.c +0 -0
@@ -1058,6 +1063,8 @@ static int acp_audio_probe(struct

platform_device

Quoted 12 lines
Quoted 12 lines
sound/soc/amd/acp-pcm-dma.c +2 -0
 *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'
--
2.7.4

maintainer
#5 lore raw

Applied "ASoC: amd: Add error checking to probe function" to the asoc tree

In reply to Guenter Roeck

The patch

ASoC: amd: Add error checking to probe function

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From fdaa451107ce543d345a339b4d5e20e8e4bac396 Mon Sep 17 00:00:00 2001

From: Guenter Roeck <[email protected]>
Date: Mon, 20 Nov 2017 20:27:56 -0800
Subject: [PATCH] ASoC: amd: Add error checking to probe function

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]>
---
 sound/soc/amd/acp-pcm-dma.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/amd/acp-pcm-dma.c +7 -0
index 9f521a55d610..b5e41df6bb3a 100644
@@ -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'
Signature · 1 line
2.15.0