Stop calling request_irq(), etc. with invalid IRQs in the USB drivers`
Subsystems (2)
v3 cover Stop calling request_irq(), etc. with invalid IRQs in the USB drivers`
Here are 2 patches against the 'usb-linus' branch of GregKH's 'usb.git' repo. The affected drivers call platform_get_irq() but largely ignore its result -- they blithely pass the negative error codes to request_irq() (and its ilk) which expects *unsinged* IRQ #s. Stop doing that by checking what exactly platform_get_irq() returns.
I've removed 7 patches that GregKH has applied to the usb-testing' branch (holler if this isn't enough).
[1/2] usb: host: ohci-tmio: add IRQ check
[2/2] usb: phy: tahvo: add IRQ check
PATCH v3 1/2 usb: host: ohci-tmio: add IRQ check
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.
---
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(+)
drivers/usb/host/ohci-tmio.c +3 -0
@@ -202,6 +202,9 @@ static int ohci_hcd_tmio_drv_probe(strucif (!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 ;
Re: [PATCH v3 1/2] usb: host: ohci-tmio: add IRQ check
Quoted 10 lines · Sergey Shtylyov
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 #), causingrequest_irq()that it calls to fail with-EINVAL, overriding an original error code. Stop callingusb_add_hcd()with the invalid IRQ #s.Fixes 78c73414f4f6 ("USB: ohci: add support for tmio-ohci cell")Signed-off-by Sergey Shtylyov <[email protected]>---
Quoted 21 lines
Changes in version 3:
- move the IRQ check higher inohci_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
===================================================================drivers/usb/host/ohci-tmio.c +3
-0@@ -202,6 +202,9 @@ static int ohci_hcd_tmio_drv_probe(strucif (!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 ;
PATCH v3 2/2 usb: phy: tahvo: add IRQ check
In reply to Sergey ShtylyovThe driver neglects to check the result of platform_get_irq()'s call and blithely passes the negative error codes to request_threaded_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL, overriding an original error code. Stop calling request_threaded_irq() with the invalid IRQ #s.
--- drivers/usb/phy/phy-tahvo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/phy/phy-tahvo.c +3 -1
@@ -393,7 +393,9 @@ static int tahvo_usb_probe(struct platfodev_set_drvdata (&pdev->dev, tu); - tu->irq =platform_get_irq (pdev,0 ); + tu->irq = ret =platform_get_irq (pdev,0 ); +if (ret <0 ) +return ret; ret =request_threaded_irq (tu->irq,NULL , tahvo_usb_vbus_interrupt,IRQF_ONESHOT ,"tahvo-vbus" , tu);
Re: [PATCH v3 2/2] usb: phy: tahvo: add IRQ check
Quoted 8 lines · Sergey Shtylyov
The driver neglects to check the result of platform_get_irq()'s call and blithely passes the negative error codes to
request_threaded_irq()(which takes *unsigned* IRQ #), causing it to fail with-EINVAL, overriding an original error code. Stop callingrequest_threaded_irq()with the invalid IRQ #s.Fixes 9ba96ae5074c ("usb: omap1: Tahvo USB transceiver driver")Signed-off-by Sergey Shtylyov <[email protected]>
Signature · 1 line
balbi
Greg Kroah-Hartman
maintainerQuoted 1 line · Sergey Shtylyov
Here are 2 patches against the 'usb-linus' branch of GregKH's 'usb.git' repo.
Wait, why that branch? Please make them against the branch you want them applied to. Hopefully they will apply to the usb-next branch...
Quoted 3 lines · Greg Kroah-Hartman
Quoted 1 line
Here are 2 patches against the 'usb-linus' branch of GregKH's 'usb.git' repo.
Wait, why that branch?
What branch I'd use for the fixes then?
Quoted 2 lines
Please make them against the branch you want
them applied to. Hopefully they will apply to the usb-next branch...
I didn't intend them for usb-next but looks like they apply there too.
MBR, Sergey
Greg Kroah-Hartman
maintainerQuoted 7 lines · Sergey Shtylyov
Quoted 3 lines · Greg Kroah-Hartman
Quoted 1 line
Here are 2 patches against the 'usb-linus' branch of GregKH's 'usb.git' repo.
Wait, why that branch?
What branch I'd use for the fixes then?
Ah, you really want this in for 5.14-final? People are hitting this issue now?
Quoted 4 lines
Quoted 2 lines
Please make them against the branch you want
them applied to. Hopefully they will apply to the usb-next branch...I didn't intend them for usb-next but looks like they apply there too.
I think it belongs there as a "nice cleanup to have", right?
thanks,
greg k-h
Quoted 7 lines · Greg Kroah-Hartman
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Here are 2 patches against the 'usb-linus' branch of GregKH's 'usb.git' repo.
Wait, why that branch?
What branch I'd use for the fixes then?
Ah, you really want this in for 5.14-final?
Not necessarily, it's your call. But all the patches are fixes.
Quoted 1 line
People are hitting this issue now?
No, the patches ware all the result of the code reviews...
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Please make them against the branch you want
them applied to. Hopefully they will apply to the usb-next branch...I didn't intend them for usb-next but looks like they apply there too.
I think it belongs there as a "nice cleanup to have", right?
No, they're definitely not cleanups and all have the "Fixes:" tags, so going
to end up in the stable trees (some already have).
There's going to be 10-patch series soon, all fixing the deferred probing due
to platfrorm_get_irq()...
Luckily, the USB tree doesn't shave the 3rd kind of platfrorm_get_irq() bugs:
treating 0 as error and returning it immediately along with the negative values, without doing the remaining part of probe...
Quoted 3 lines
thanks,
greg k-h
MBR, Sergey