linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: host: fsl-mph-dr-of: check return of dma_set_mask()
@ 2020-10-10  6:03 Ran Wang
  2020-10-10 23:40 ` Peter Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Ran Wang @ 2020-10-10  6:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Chen, Jun Li, open list:USB SUBSYSTEM, open list, Ran Wang

fsl_usb2_device_register() should stop init if dma_set_mask() return
error.

Fixes: cae058610465 ("drivers/usb/host: fsl: Set DMA_MASK of usb platform device")
Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 drivers/usb/host/fsl-mph-dr-of.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index ae8f60f..44a7e58 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -94,10 +94,13 @@ static struct platform_device *fsl_usb2_device_register(
 
 	pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
 
-	if (!pdev->dev.dma_mask)
+	if (!pdev->dev.dma_mask) {
 		pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask;
-	else
-		dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+	} else {
+		retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+		if (retval)
+			goto error;
+	}
 
 	retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
 	if (retval)
-- 
2.7.4


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

* Re: [PATCH] usb: host: fsl-mph-dr-of: check return of dma_set_mask()
  2020-10-10  6:03 [PATCH] usb: host: fsl-mph-dr-of: check return of dma_set_mask() Ran Wang
@ 2020-10-10 23:40 ` Peter Chen
  2020-10-14  7:49   ` Ran Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Chen @ 2020-10-10 23:40 UTC (permalink / raw)
  To: Ran Wang; +Cc: Greg Kroah-Hartman, Jun Li, open list:USB SUBSYSTEM, open list

On 20-10-10 14:03:08, Ran Wang wrote:
> fsl_usb2_device_register() should stop init if dma_set_mask() return
> error.
> 
> Fixes: cae058610465 ("drivers/usb/host: fsl: Set DMA_MASK of usb platform device")
> Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> ---
>  drivers/usb/host/fsl-mph-dr-of.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
> index ae8f60f..44a7e58 100644
> --- a/drivers/usb/host/fsl-mph-dr-of.c
> +++ b/drivers/usb/host/fsl-mph-dr-of.c
> @@ -94,10 +94,13 @@ static struct platform_device *fsl_usb2_device_register(
>  
>  	pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
>  
> -	if (!pdev->dev.dma_mask)
> +	if (!pdev->dev.dma_mask) {
>  		pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask;
> -	else
> -		dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> +	} else {
> +		retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> +		if (retval)
> +			goto error;
> +	}
>  
>  	retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
>  	if (retval)
> -- 
> 2.7.4
> 

Reviewed-by: Peter Chen <peter.chen@nxp.com>

One more place need to fix, if platform_device_alloc returns NULL,
it should not call platform_device_put to release platform
device memory.

	pdev = platform_device_alloc(name, id);
	if (!pdev) {
		retval = -ENOMEM;
		goto error;
	}
	...
error:
	platform_device_put(pdev);
	return ERR_PTR(retval);
-- 

Thanks,
Peter Chen

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

* RE: [PATCH] usb: host: fsl-mph-dr-of: check return of dma_set_mask()
  2020-10-10 23:40 ` Peter Chen
@ 2020-10-14  7:49   ` Ran Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Ran Wang @ 2020-10-14  7:49 UTC (permalink / raw)
  To: Peter Chen; +Cc: Greg Kroah-Hartman, Jun Li, open list:USB SUBSYSTEM, open list

Hi Peter,

On Sunday, October 11, 2020 7:41 AM Peter Chen wrote:
> 
> On 20-10-10 14:03:08, Ran Wang wrote:
> > fsl_usb2_device_register() should stop init if dma_set_mask() return
> > error.
> >
> > Fixes: cae058610465 ("drivers/usb/host: fsl: Set DMA_MASK of usb
> > platform device")
> > Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
> > ---
> >  drivers/usb/host/fsl-mph-dr-of.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/host/fsl-mph-dr-of.c
> > b/drivers/usb/host/fsl-mph-dr-of.c
> > index ae8f60f..44a7e58 100644
> > --- a/drivers/usb/host/fsl-mph-dr-of.c
> > +++ b/drivers/usb/host/fsl-mph-dr-of.c
> > @@ -94,10 +94,13 @@ static struct platform_device
> > *fsl_usb2_device_register(
> >
> >  	pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
> >
> > -	if (!pdev->dev.dma_mask)
> > +	if (!pdev->dev.dma_mask) {
> >  		pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask;
> > -	else
> > -		dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> > +	} else {
> > +		retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> > +		if (retval)
> > +			goto error;
> > +	}
> >
> >  	retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
> >  	if (retval)
> > --
> > 2.7.4
> >
> 
> Reviewed-by: Peter Chen <peter.chen@nxp.com>
> 
> One more place need to fix, if platform_device_alloc returns NULL,
> it should not call platform_device_put to release platform
> device memory.
> 
> 	pdev = platform_device_alloc(name, id);
> 	if (!pdev) {
> 		retval = -ENOMEM;
> 		goto error;
> 	}
> 	...
> error:
> 	platform_device_put(pdev);
> 	return ERR_PTR(retval);

Got it, let me check this later.

Thanks & Regards,
Ran


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

end of thread, other threads:[~2020-10-14  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10  6:03 [PATCH] usb: host: fsl-mph-dr-of: check return of dma_set_mask() Ran Wang
2020-10-10 23:40 ` Peter Chen
2020-10-14  7:49   ` Ran Wang

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).