linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] dmaengine: ti: omap-dma: don't allow a null od->plat pointer to be dereferenced
@ 2020-01-06 12:23 Colin King
  2020-01-07 11:59 ` Peter Ujfalusi
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2020-01-06 12:23 UTC (permalink / raw)
  To: Dan Williams, Vinod Koul, Peter Ujfalusi, Tony Lindgren, dmaengine
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently when the call to dev_get_platdata returns null the driver issues
a warning and then later dereferences the null pointer.  Avoid this issue
by returning -EPROBE_DEFER errror rather when the platform data is null.

Addresses-Coverity: ("Dereference after null check")
Fixes: 211010aeb097 ("dmaengine: ti: omap-dma: Pass sdma auxdata to driver and use it")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/dma/ti/omap-dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
index fc8f7b2fc7b3..335c3fa7a3b1 100644
--- a/drivers/dma/ti/omap-dma.c
+++ b/drivers/dma/ti/omap-dma.c
@@ -1658,8 +1658,10 @@ static int omap_dma_probe(struct platform_device *pdev)
 	if (conf) {
 		od->cfg = conf;
 		od->plat = dev_get_platdata(&pdev->dev);
-		if (!od->plat)
+		if (!od->plat) {
 			dev_warn(&pdev->dev, "no sdma auxdata needed?\n");
+			return -EPROBE_DEFER;
+		}
 	} else {
 		od->cfg = &default_cfg;
 
-- 
2.24.0


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

* Re: [PATCH][next] dmaengine: ti: omap-dma: don't allow a null od->plat pointer to be dereferenced
  2020-01-06 12:23 [PATCH][next] dmaengine: ti: omap-dma: don't allow a null od->plat pointer to be dereferenced Colin King
@ 2020-01-07 11:59 ` Peter Ujfalusi
  2020-01-08  7:20   ` Peter Ujfalusi
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Ujfalusi @ 2020-01-07 11:59 UTC (permalink / raw)
  To: Colin King, Dan Williams, Vinod Koul, Tony Lindgren, dmaengine
  Cc: kernel-janitors, linux-kernel

Colin,

On 06/01/2020 14.23, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently when the call to dev_get_platdata returns null the driver issues
> a warning and then later dereferences the null pointer.  Avoid this issue
> by returning -EPROBE_DEFER errror rather when the platform data is null.

Thank you for noticing it!

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> Addresses-Coverity: ("Dereference after null check")
> Fixes: 211010aeb097 ("dmaengine: ti: omap-dma: Pass sdma auxdata to driver and use it")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/dma/ti/omap-dma.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
> index fc8f7b2fc7b3..335c3fa7a3b1 100644
> --- a/drivers/dma/ti/omap-dma.c
> +++ b/drivers/dma/ti/omap-dma.c
> @@ -1658,8 +1658,10 @@ static int omap_dma_probe(struct platform_device *pdev)
>  	if (conf) {
>  		od->cfg = conf;
>  		od->plat = dev_get_platdata(&pdev->dev);
> -		if (!od->plat)
> +		if (!od->plat) {
>  			dev_warn(&pdev->dev, "no sdma auxdata needed?\n");
> +			return -EPROBE_DEFER;
> +		}
>  	} else {
>  		od->cfg = &default_cfg;
>  
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH][next] dmaengine: ti: omap-dma: don't allow a null od->plat pointer to be dereferenced
  2020-01-07 11:59 ` Peter Ujfalusi
@ 2020-01-08  7:20   ` Peter Ujfalusi
  2020-01-08 22:05     ` Tony Lindgren
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Ujfalusi @ 2020-01-08  7:20 UTC (permalink / raw)
  To: Colin King, Dan Williams, Vinod Koul, Tony Lindgren, dmaengine
  Cc: kernel-janitors, linux-kernel

Colin, Tony,

On 07/01/2020 13.59, Peter Ujfalusi wrote:
> Colin,
> 
> On 06/01/2020 14.23, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently when the call to dev_get_platdata returns null the driver issues
>> a warning and then later dereferences the null pointer.  Avoid this issue
>> by returning -EPROBE_DEFER errror rather when the platform data is null.
> 
> Thank you for noticing it!
> 
> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> 
>> Addresses-Coverity: ("Dereference after null check")
>> Fixes: 211010aeb097 ("dmaengine: ti: omap-dma: Pass sdma auxdata to driver and use it")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/dma/ti/omap-dma.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
>> index fc8f7b2fc7b3..335c3fa7a3b1 100644
>> --- a/drivers/dma/ti/omap-dma.c
>> +++ b/drivers/dma/ti/omap-dma.c
>> @@ -1658,8 +1658,10 @@ static int omap_dma_probe(struct platform_device *pdev)
>>  	if (conf) {
>>  		od->cfg = conf;
>>  		od->plat = dev_get_platdata(&pdev->dev);
>> -		if (!od->plat)
>> +		if (!od->plat) {
>>  			dev_warn(&pdev->dev, "no sdma auxdata needed?\n");
>> +			return -EPROBE_DEFER;

I think we should make the print as dev_err("&pdev->dev,
"omap_system_dma_plat_info is missing") and return with -ENODEV. The
omap_system_dma_plat_info is _needed_ and if we have booted with device
tree it is not going to appear later.

Tony, what do you think?

>> +		}
>>  	} else {
>>  		od->cfg = &default_cfg;
>>  
>>

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

* Re: [PATCH][next] dmaengine: ti: omap-dma: don't allow a null od->plat pointer to be dereferenced
  2020-01-08  7:20   ` Peter Ujfalusi
@ 2020-01-08 22:05     ` Tony Lindgren
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2020-01-08 22:05 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Colin King, Dan Williams, Vinod Koul, dmaengine, kernel-janitors,
	linux-kernel

* Peter Ujfalusi <peter.ujfalusi@ti.com> [200108 07:20]:
> Colin, Tony,
> 
> On 07/01/2020 13.59, Peter Ujfalusi wrote:
> > Colin,
> > 
> > On 06/01/2020 14.23, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> Currently when the call to dev_get_platdata returns null the driver issues
> >> a warning and then later dereferences the null pointer.  Avoid this issue
> >> by returning -EPROBE_DEFER errror rather when the platform data is null.
> > 
> > Thank you for noticing it!
> > 
> > Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> > 
> >> Addresses-Coverity: ("Dereference after null check")
> >> Fixes: 211010aeb097 ("dmaengine: ti: omap-dma: Pass sdma auxdata to driver and use it")
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >> ---
> >>  drivers/dma/ti/omap-dma.c | 4 +++-
> >>  1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
> >> index fc8f7b2fc7b3..335c3fa7a3b1 100644
> >> --- a/drivers/dma/ti/omap-dma.c
> >> +++ b/drivers/dma/ti/omap-dma.c
> >> @@ -1658,8 +1658,10 @@ static int omap_dma_probe(struct platform_device *pdev)
> >>  	if (conf) {
> >>  		od->cfg = conf;
> >>  		od->plat = dev_get_platdata(&pdev->dev);
> >> -		if (!od->plat)
> >> +		if (!od->plat) {
> >>  			dev_warn(&pdev->dev, "no sdma auxdata needed?\n");
> >> +			return -EPROBE_DEFER;
> 
> I think we should make the print as dev_err("&pdev->dev,
> "omap_system_dma_plat_info is missing") and return with -ENODEV. The
> omap_system_dma_plat_info is _needed_ and if we have booted with device
> tree it is not going to appear later.
> 
> Tony, what do you think?

Yes makes sense, the auxdata is needed for the quirks for now.
Eventually the quirks can be set directly in the dmaengine driver
based on compatible and soc_device_match().

Regards,

Tony

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

end of thread, other threads:[~2020-01-08 22:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06 12:23 [PATCH][next] dmaengine: ti: omap-dma: don't allow a null od->plat pointer to be dereferenced Colin King
2020-01-07 11:59 ` Peter Ujfalusi
2020-01-08  7:20   ` Peter Ujfalusi
2020-01-08 22:05     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).