All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: amd: Add error checking to probe function
@ 2017-11-21  4:27 ` Guenter Roeck
  0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2017-11-21  4:27 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, Guenter Roeck, Alex Deucher, Dominik Behr,
	Daniel Kurtz

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 <alexander.deucher@amd.com>
Cc: Dominik Behr <dbehr@chromium.org>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
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(+)

diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index 9f521a55d610..b5e41df6bb3a 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -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'
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] ASoC: amd: Add error checking to probe function
@ 2017-11-21  4:27 ` Guenter Roeck
  0 siblings, 0 replies; 10+ messages in thread
From: Guenter Roeck @ 2017-11-21  4:27 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: alsa-devel, Dominik Behr, linux-kernel, Daniel Kurtz,
	Takashi Iwai, Mark Brown, Alex Deucher, Guenter Roeck

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 <alexander.deucher@amd.com>
Cc: Dominik Behr <dbehr@chromium.org>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
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(+)

diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index 9f521a55d610..b5e41df6bb3a 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -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'
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* RE: [PATCH] ASoC: amd: Add error checking to probe function
  2017-11-21  4:27 ` Guenter Roeck
  (?)
@ 2017-11-21  4:47 ` Deucher, Alexander
  2017-11-21  6:15     ` Agrawal, Akshu
  -1 siblings, 1 reply; 10+ messages in thread
From: Deucher, Alexander @ 2017-11-21  4:47 UTC (permalink / raw)
  To: 'Guenter Roeck',
	Liam Girdwood, Mukunda, Vijendar, Agrawal, Akshu
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, Dominik Behr, Daniel Kurtz

> -----Original Message-----
> From: Guenter Roeck [mailto:groeck7@gmail.com] 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;
> linux-kernel@vger.kernel.org; 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.
> 
> Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver")
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Dominik Behr <dbehr@chromium.org>
> Cc: Daniel Kurtz <djkurtz@chromium.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> 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.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> 
>  sound/soc/amd/acp-pcm-dma.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-
> dma.c
> index 9f521a55d610..b5e41df6bb3a 100644
> --- a/sound/soc/amd/acp-pcm-dma.c
> +++ b/sound/soc/amd/acp-pcm-dma.c
> @@ -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'
> --
> 2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: amd: Add error checking to probe function
  2017-11-21  4:47 ` Deucher, Alexander
@ 2017-11-21  6:15     ` Agrawal, Akshu
  0 siblings, 0 replies; 10+ messages in thread
From: Agrawal, Akshu @ 2017-11-21  6:15 UTC (permalink / raw)
  To: Deucher, Alexander, 'Guenter Roeck',
	Liam Girdwood, Mukunda, Vijendar
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, Dominik Behr, Daniel Kurtz



On 11/21/2017 10:17 AM, Deucher, Alexander wrote:
>> -----Original Message-----
>> From: Guenter Roeck [mailto:groeck7@gmail.com] 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;
>> linux-kernel@vger.kernel.org; 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.
>>
>> Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver")
>> Cc: Alex Deucher <alexander.deucher@amd.com>
>> Cc: Dominik Behr <dbehr@chromium.org>
>> Cc: Daniel Kurtz <djkurtz@chromium.org>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> 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?

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.

> 
> The patch looks good to me.
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> 
>>
>>   sound/soc/amd/acp-pcm-dma.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-
>> dma.c
>> index 9f521a55d610..b5e41df6bb3a 100644
>> --- a/sound/soc/amd/acp-pcm-dma.c
>> +++ b/sound/soc/amd/acp-pcm-dma.c
>> @@ -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'
>> --
>> 2.7.4
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: amd: Add error checking to probe function
@ 2017-11-21  6:15     ` Agrawal, Akshu
  0 siblings, 0 replies; 10+ messages in thread
From: Agrawal, Akshu @ 2017-11-21  6:15 UTC (permalink / raw)
  To: Deucher, Alexander, 'Guenter Roeck',
	Liam Girdwood, Mukunda, Vijendar
  Cc: alsa-devel, Dominik Behr, linux-kernel, Daniel Kurtz,
	Takashi Iwai, Mark Brown



On 11/21/2017 10:17 AM, Deucher, Alexander wrote:
>> -----Original Message-----
>> From: Guenter Roeck [mailto:groeck7@gmail.com] 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;
>> linux-kernel@vger.kernel.org; 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.
>>
>> Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver")
>> Cc: Alex Deucher <alexander.deucher@amd.com>
>> Cc: Dominik Behr <dbehr@chromium.org>
>> Cc: Daniel Kurtz <djkurtz@chromium.org>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> 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?

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.

> 
> The patch looks good to me.
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> 
>>
>>   sound/soc/amd/acp-pcm-dma.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-
>> dma.c
>> index 9f521a55d610..b5e41df6bb3a 100644
>> --- a/sound/soc/amd/acp-pcm-dma.c
>> +++ b/sound/soc/amd/acp-pcm-dma.c
>> @@ -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'
>> --
>> 2.7.4
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH] ASoC: amd: Add error checking to probe function
  2017-11-21  6:15     ` Agrawal, Akshu
  (?)
@ 2017-11-21 15:08     ` Deucher, Alexander
  2017-11-22  9:52         ` Mukunda,Vijendar
  -1 siblings, 1 reply; 10+ messages in thread
From: Deucher, Alexander @ 2017-11-21 15:08 UTC (permalink / raw)
  To: Agrawal, Akshu, 'Guenter Roeck',
	Liam Girdwood, Mukunda, Vijendar
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, Dominik Behr, Daniel Kurtz

> -----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; alsa-devel@alsa-project.org;
> linux-kernel@vger.kernel.org; Dominik Behr; Daniel Kurtz
> Subject: Re: [PATCH] ASoC: amd: Add error checking to probe function
> 
> 
> 
> On 11/21/2017 10:17 AM, Deucher, Alexander wrote:
> >> -----Original Message-----
> >> From: Guenter Roeck [mailto:groeck7@gmail.com] 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;
> >> linux-kernel@vger.kernel.org; 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.
> >>
> >> Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver")
> >> Cc: Alex Deucher <alexander.deucher@amd.com>
> >> Cc: Dominik Behr <dbehr@chromium.org>
> >> Cc: Daniel Kurtz <djkurtz@chromium.org>
> >> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> >> ---
> >> 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?
> 
> 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

> >
> > The patch looks good to me.
> > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> >
> >>
> >>   sound/soc/amd/acp-pcm-dma.c | 7 +++++++
> >>   1 file changed, 7 insertions(+)
> >>
> >> diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-
> >> dma.c
> >> index 9f521a55d610..b5e41df6bb3a 100644
> >> --- a/sound/soc/amd/acp-pcm-dma.c
> >> +++ b/sound/soc/amd/acp-pcm-dma.c
> >> @@ -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'
> >> --
> >> 2.7.4
> >

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: amd: Add error checking to probe function
  2017-11-21 15:08     ` Deucher, Alexander
@ 2017-11-22  9:52         ` Mukunda,Vijendar
  0 siblings, 0 replies; 10+ messages in thread
From: Mukunda,Vijendar @ 2017-11-22  9:52 UTC (permalink / raw)
  To: Deucher, Alexander, Agrawal, Akshu, 'Guenter Roeck',
	Liam Girdwood
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, Dominik Behr, Daniel Kurtz



On Tuesday 21 November 2017 08:38 PM, Deucher, Alexander wrote:
>> -----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; alsa-devel@alsa-project.org;
>> linux-kernel@vger.kernel.org; Dominik Behr; Daniel Kurtz
>> Subject: Re: [PATCH] ASoC: amd: Add error checking to probe function
>>
>>
>>
>> On 11/21/2017 10:17 AM, Deucher, Alexander wrote:
>>>> -----Original Message-----
>>>> From: Guenter Roeck [mailto:groeck7@gmail.com] 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;
>>>> linux-kernel@vger.kernel.org; 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.
>>>>
>>>> Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver")
>>>> Cc: Alex Deucher <alexander.deucher@amd.com>
>>>> Cc: Dominik Behr <dbehr@chromium.org>
>>>> Cc: Daniel Kurtz <djkurtz@chromium.org>
>>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>>> ---
>>>> 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?
>> 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
>   
on top of this patch will add more error checks and submit a new patch
>>> The patch looks good to me.
>>> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>>>
>>>>    sound/soc/amd/acp-pcm-dma.c | 7 +++++++
>>>>    1 file changed, 7 insertions(+)
>>>>
>>>> diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-
>>>> dma.c
>>>> index 9f521a55d610..b5e41df6bb3a 100644
>>>> --- a/sound/soc/amd/acp-pcm-dma.c
>>>> +++ b/sound/soc/amd/acp-pcm-dma.c
>>>> @@ -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'
>>>> --
>>>> 2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ASoC: amd: Add error checking to probe function
@ 2017-11-22  9:52         ` Mukunda,Vijendar
  0 siblings, 0 replies; 10+ messages in thread
From: Mukunda,Vijendar @ 2017-11-22  9:52 UTC (permalink / raw)
  To: Deucher, Alexander, Agrawal, Akshu, 'Guenter Roeck',
	Liam Girdwood
  Cc: alsa-devel, Dominik Behr, linux-kernel, Daniel Kurtz,
	Takashi Iwai, Mark Brown



On Tuesday 21 November 2017 08:38 PM, Deucher, Alexander wrote:
>> -----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; alsa-devel@alsa-project.org;
>> linux-kernel@vger.kernel.org; Dominik Behr; Daniel Kurtz
>> Subject: Re: [PATCH] ASoC: amd: Add error checking to probe function
>>
>>
>>
>> On 11/21/2017 10:17 AM, Deucher, Alexander wrote:
>>>> -----Original Message-----
>>>> From: Guenter Roeck [mailto:groeck7@gmail.com] 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;
>>>> linux-kernel@vger.kernel.org; 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.
>>>>
>>>> Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver")
>>>> Cc: Alex Deucher <alexander.deucher@amd.com>
>>>> Cc: Dominik Behr <dbehr@chromium.org>
>>>> Cc: Daniel Kurtz <djkurtz@chromium.org>
>>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>>> ---
>>>> 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?
>> 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
>   
on top of this patch will add more error checks and submit a new patch
>>> The patch looks good to me.
>>> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>>>
>>>>    sound/soc/amd/acp-pcm-dma.c | 7 +++++++
>>>>    1 file changed, 7 insertions(+)
>>>>
>>>> diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-
>>>> dma.c
>>>> index 9f521a55d610..b5e41df6bb3a 100644
>>>> --- a/sound/soc/amd/acp-pcm-dma.c
>>>> +++ b/sound/soc/amd/acp-pcm-dma.c
>>>> @@ -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'
>>>> --
>>>> 2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Applied "ASoC: amd: Add error checking to probe function" to the asoc tree
  2017-11-21  4:27 ` Guenter Roeck
@ 2017-11-27 18:52   ` Mark Brown
  -1 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-11-27 18:52 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Alex Deucher, Dominik Behr, Daniel Kurtz, Mark Brown,
	Liam Girdwood, alsa-devel, Dominik Behr, linux-kernel,
	Daniel Kurtz, Takashi Iwai, Mark Brown, Alex Deucher, alsa-devel

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

>From fdaa451107ce543d345a339b4d5e20e8e4bac396 Mon Sep 17 00:00:00 2001
From: Guenter Roeck <linux@roeck-us.net>
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 <alexander.deucher@amd.com>
Cc: Dominik Behr <dbehr@chromium.org>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/amd/acp-pcm-dma.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index 9f521a55d610..b5e41df6bb3a 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -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'
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Applied "ASoC: amd: Add error checking to probe function" to the asoc tree
@ 2017-11-27 18:52   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2017-11-27 18:52 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Alex Deucher, Dominik Behr, Daniel Kurtz, Mark Brown,
	Liam Girdwood, alsa-devel

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

>From fdaa451107ce543d345a339b4d5e20e8e4bac396 Mon Sep 17 00:00:00 2001
From: Guenter Roeck <linux@roeck-us.net>
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 <alexander.deucher@amd.com>
Cc: Dominik Behr <dbehr@chromium.org>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/amd/acp-pcm-dma.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index 9f521a55d610..b5e41df6bb3a 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -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'
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-11-27 18:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-21  4:27 [PATCH] ASoC: amd: Add error checking to probe function Guenter Roeck
2017-11-21  4:27 ` Guenter Roeck
2017-11-21  4:47 ` Deucher, Alexander
2017-11-21  6:15   ` Agrawal, Akshu
2017-11-21  6:15     ` Agrawal, Akshu
2017-11-21 15:08     ` Deucher, Alexander
2017-11-22  9:52       ` Mukunda,Vijendar
2017-11-22  9:52         ` Mukunda,Vijendar
2017-11-27 18:52 ` Applied "ASoC: amd: Add error checking to probe function" to the asoc tree Mark Brown
2017-11-27 18:52   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.