diff mbox series

[v3,1/2] usb: host: ohci-tmio: add IRQ check

Message ID 402e1a45-a0a4-0e08-566a-7ca1331506b1@omp.ru (mailing list archive)
State Accepted
Commit 4ac5132e8a4300637a2da8f5d6bc7650db735b8a
Headers show
Series Stop calling request_irq(), etc. with invalid IRQs in the USB drivers` | expand

Commit Message

Sergey Shtylyov Aug. 13, 2021, 8:30 p.m. UTC
The driver neglects to check the  result of platform_get_irq()'s call and
blithely passes the negative error codes to usb_add_hcd() (which takes
*unsigned* IRQ #), causing request_irq() that it calls to fail with
-EINVAL, overriding an original error code. Stop calling usb_add_hcd()
with the invalid IRQ #s.

Fixes: 78c73414f4f6 ("USB: ohci: add support for tmio-ohci cell")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
Changes in version 3:
- move the IRQ check higher in ohci_hcd_tmio_drv_probe(), to be closer to
  platfrom_get_irq()'s call.

 drivers/usb/host/ohci-tmio.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Alan Stern Aug. 14, 2021, 1:45 a.m. UTC | #1
On Fri, Aug 13, 2021 at 11:30:18PM +0300, Sergey Shtylyov wrote:
> The driver neglects to check the  result of platform_get_irq()'s call and
> blithely passes the negative error codes to usb_add_hcd() (which takes
> *unsigned* IRQ #), causing request_irq() that it calls to fail with
> -EINVAL, overriding an original error code. Stop calling usb_add_hcd()
> with the invalid IRQ #s.
> 
> Fixes: 78c73414f4f6 ("USB: ohci: add support for tmio-ohci cell")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> ---

Acked-by: Alan Stern <stern@rowland.harvard.edu>

> Changes in version 3:
> - move the IRQ check higher in ohci_hcd_tmio_drv_probe(), to be closer to
>   platfrom_get_irq()'s call.
> 
>  drivers/usb/host/ohci-tmio.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> Index: usb/drivers/usb/host/ohci-tmio.c
> ===================================================================
> --- usb.orig/drivers/usb/host/ohci-tmio.c
> +++ usb/drivers/usb/host/ohci-tmio.c
> @@ -202,6 +202,9 @@ static int ohci_hcd_tmio_drv_probe(struc
>  	if (!cell)
>  		return -EINVAL;
>  
> +	if (irq < 0)
> +		return irq;
> +
>  	hcd = usb_create_hcd(&ohci_tmio_hc_driver, &dev->dev, dev_name(&dev->dev));
>  	if (!hcd) {
>  		ret = -ENOMEM;
diff mbox series

Patch

Index: usb/drivers/usb/host/ohci-tmio.c
===================================================================
--- usb.orig/drivers/usb/host/ohci-tmio.c
+++ usb/drivers/usb/host/ohci-tmio.c
@@ -202,6 +202,9 @@  static int ohci_hcd_tmio_drv_probe(struc
 	if (!cell)
 		return -EINVAL;
 
+	if (irq < 0)
+		return irq;
+
 	hcd = usb_create_hcd(&ohci_tmio_hc_driver, &dev->dev, dev_name(&dev->dev));
 	if (!hcd) {
 		ret = -ENOMEM;