mbox series

[v2,0/9] Stop calling devm_request_irq() with invalid IRQs in the USB drivers

Message ID 717ddd7c-22cd-d82c-e43d-80254718c801@omp.ru
Headers show
Series Stop calling devm_request_irq() with invalid IRQs in the USB drivers | expand

Message

Sergey Shtylyov Aug. 8, 2021, 8:30 p.m. UTC
Here are 9 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.

[1/9] usb: dwc3: meson-g12a: add IRQ check
[2/9] usb: dwc3: qcom: add IRQ check
[3/61] usb: gadget: udc: at91: add IRQ check
[4/9] usb: gadget: udc: s3c2410: add IRQ check
[5/9] usb: host: ohci-tmio: add IRQ check
[6/9] usb: misc: brcmstb-usb-pinmap: add IRQ check
[7/9] usb: phy: fsl-usb: add IRQ check
[8/9] usb: phy: tahvo: add IRQ check
[9/9] usb: phy: twl6030: add IRQ checks

Comments

Martin Blumenstingl Aug. 8, 2021, 8:50 p.m. UTC | #1
Hi Sergey,

On Sun, Aug 8, 2021 at 10:37 PM Sergey Shtylyov <s.shtylyov@omp.ru> wrote:
>
> The driver neglects to check the result of platform_get_irq()'s call and
> blithely passes the negative error codes to devm_request_threaded_irq()
> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL, overriding
> an original error code. Stop calling devm_request_threaded_irq() with the
> invalid IRQ #s.
>
> Fixes: f90db10779ad ("usb: dwc3: meson-g12a: Add support for IRQ based OTG switching")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Thanks for spotting and fixing this issue!
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Sergey Shtylyov Aug. 8, 2021, 9:01 p.m. UTC | #2
Oops, duplicate patch. Scratch the series, I'm going to restart posting tomorrow... :-)
Felipe Balbi Aug. 9, 2021, 10:07 a.m. UTC | #3
Sergey Shtylyov <s.shtylyov@omp.ru> writes:

> The driver neglects to check the result of platform_get_irq()'s call and

> blithely passes the negative error codes to devm_request_irq() (which takes

> *unsigned* IRQ #), causing it to fail with -EINVAL, overriding an original

> error code. Stop calling devm_request_irq() with the invalid IRQ #s.

>

> Fixes: 8b2e76687b39 ("USB: AT91 UDC updates, mostly power management")

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

>

> ---

>  drivers/usb/gadget/udc/at91_udc.c |    4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

>

> Index: usb/drivers/usb/gadget/udc/at91_udc.c

> ===================================================================

> --- usb.orig/drivers/usb/gadget/udc/at91_udc.c

> +++ usb/drivers/usb/gadget/udc/at91_udc.c

> @@ -1876,7 +1876,9 @@ static int at91udc_probe(struct platform

>  	clk_disable(udc->iclk);

>  

>  	/* request UDC and maybe VBUS irqs */

> -	udc->udp_irq = platform_get_irq(pdev, 0);

> +	udc->udp_irq = retval = platform_get_irq(pdev, 0);

> +	if (retval < 0)

> +		goto err_unprepare_iclk;


let's avoid multiple assignments in one line. How about:

	if (udc->udp_irq < 0) {
        	retval = udc->udp_irq;
                goto err_unprepare_iclk;
        }

-- 
balbi
Felipe Balbi Aug. 9, 2021, 10:08 a.m. UTC | #4
Sergey Shtylyov <s.shtylyov@omp.ru> writes:

> The driver neglects to check the result of platform_get_irq()'s call and

> blithely passes the negative error codes to devm_request_threaded_irq()

> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL, overriding

> an original error code. Stop calling devm_request_threaded_irq() with the

> invalid IRQ #s.

>

> Fixes: f90db10779ad ("usb: dwc3: meson-g12a: Add support for IRQ based OTG switching")

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>


Acked-by: Felipe Balbi <balbi@kernel.org>



-- 
balbi
Felipe Balbi Aug. 9, 2021, 10:09 a.m. UTC | #5
Sergey Shtylyov <s.shtylyov@omp.ru> writes:

> The driver neglects to check the result of platform_get_irq()'s call and
> blithely passes the negative error codes to devm_request_irq() (which takes
> *unsigned* IRQ #), causing it to fail with -EINVAL, overriding an original
> error code. Stop calling devm_request_irq() with the invalid IRQ #s.
>
> Fixes: 8b2e76687b39 ("USB: AT91 UDC updates, mostly power management")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

Acked-by: Felipe Balbi <balbi@kernel.org>
Greg Kroah-Hartman Aug. 13, 2021, 6:58 a.m. UTC | #6
On Sun, Aug 08, 2021 at 11:30:57PM +0300, Sergey Shtylyov wrote:
> Here are 9 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.

> 

> [1/9] usb: dwc3: meson-g12a: add IRQ check

> [2/9] usb: dwc3: qcom: add IRQ check

> [3/61] usb: gadget: udc: at91: add IRQ check


61?

> [4/9] usb: gadget: udc: s3c2410: add IRQ check

> [5/9] usb: host: ohci-tmio: add IRQ check

> [6/9] usb: misc: brcmstb-usb-pinmap: add IRQ check

> [7/9] usb: phy: fsl-usb: add IRQ check

> [8/9] usb: phy: tahvo: add IRQ check

> [9/9] usb: phy: twl6030: add IRQ checks



I only see 4 patches in this series, and the 4th, did not apply to my
tree :(

Can you please fix this up and resend it correctly?

thanks,

greg k-h
Greg Kroah-Hartman Aug. 13, 2021, 7:01 a.m. UTC | #7
On Fri, Aug 13, 2021 at 08:58:58AM +0200, Greg Kroah-Hartman wrote:
> On Sun, Aug 08, 2021 at 11:30:57PM +0300, Sergey Shtylyov wrote:

> > Here are 9 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.

> > 

> > [1/9] usb: dwc3: meson-g12a: add IRQ check

> > [2/9] usb: dwc3: qcom: add IRQ check

> > [3/61] usb: gadget: udc: at91: add IRQ check

> 

> 61?

> 

> > [4/9] usb: gadget: udc: s3c2410: add IRQ check

> > [5/9] usb: host: ohci-tmio: add IRQ check

> > [6/9] usb: misc: brcmstb-usb-pinmap: add IRQ check

> > [7/9] usb: phy: fsl-usb: add IRQ check

> > [8/9] usb: phy: tahvo: add IRQ check

> > [9/9] usb: phy: twl6030: add IRQ checks

> 

> 

> I only see 4 patches in this series, and the 4th, did not apply to my

> tree :(

> 

> Can you please fix this up and resend it correctly?


Ah, see your v2 now...