diff mbox series

[v2] usb: gadget: fsl: Fix unsigned expression compared with zero in fsl_udc_probe

Message ID 20200824084234.232179-1-yebin10@huawei.com (mailing list archive)
State Accepted
Commit 87a2dfb136430c914f286e4b9870d538e559df29
Headers show
Series [v2] usb: gadget: fsl: Fix unsigned expression compared with zero in fsl_udc_probe | expand

Commit Message

yebin (H) Aug. 24, 2020, 8:42 a.m. UTC
udc_controller->irq is "unsigned int" always >= 0, but platform_get_irq may
return little than zero. So "dc_controller->irq < 0" condition is never
accessible.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Leo Li Aug. 24, 2020, 6:46 p.m. UTC | #1
> -----Original Message-----
> From: Ye Bin <yebin10@huawei.com>
> Sent: Monday, August 24, 2020 3:43 AM
> To: Leo Li <leoyang.li@nxp.com>; linux-usb@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org
> Cc: Ye Bin <yebin10@huawei.com>
> Subject: [PATCH v2] usb: gadget: fsl: Fix unsigned expression compared with
> zero in fsl_udc_probe
> 
> udc_controller->irq is "unsigned int" always >= 0, but platform_get_irq may
> return little than zero. So "dc_controller->irq < 0" condition is never
> accessible.
> 
> Signed-off-by: Ye Bin <yebin10@huawei.com>

Acked-by: Li Yang <leoyang.li@nxp.com>

> ---
>  drivers/usb/gadget/udc/fsl_udc_core.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c
> b/drivers/usb/gadget/udc/fsl_udc_core.c
> index a6f7b2594c09..3e98740b8cfc 100644
> --- a/drivers/usb/gadget/udc/fsl_udc_core.c
> +++ b/drivers/usb/gadget/udc/fsl_udc_core.c
> @@ -2439,11 +2439,12 @@ static int fsl_udc_probe(struct platform_device
> *pdev)
>  	/* DEN is bidirectional ep number, max_ep doubles the number */
>  	udc_controller->max_ep = (dccparams & DCCPARAMS_DEN_MASK)
> * 2;
> 
> -	udc_controller->irq = platform_get_irq(pdev, 0);
> -	if (udc_controller->irq <= 0) {
> -		ret = udc_controller->irq ? : -ENODEV;
> +	ret = platform_get_irq(pdev, 0);
> +	if (ret <= 0) {
> +		ret = ret ? : -ENODEV;
>  		goto err_iounmap;
>  	}
> +	udc_controller->irq = ret;
> 
>  	ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED,
>  			driver_name, udc_controller);
> --
> 2.25.4
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c
index a6f7b2594c09..3e98740b8cfc 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -2439,11 +2439,12 @@  static int fsl_udc_probe(struct platform_device *pdev)
 	/* DEN is bidirectional ep number, max_ep doubles the number */
 	udc_controller->max_ep = (dccparams & DCCPARAMS_DEN_MASK) * 2;
 
-	udc_controller->irq = platform_get_irq(pdev, 0);
-	if (udc_controller->irq <= 0) {
-		ret = udc_controller->irq ? : -ENODEV;
+	ret = platform_get_irq(pdev, 0);
+	if (ret <= 0) {
+		ret = ret ? : -ENODEV;
 		goto err_iounmap;
 	}
+	udc_controller->irq = ret;
 
 	ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED,
 			driver_name, udc_controller);