diff mbox series

[v2,20/22] usb: host: xhci-mtk: deny IRQ0

Message ID 20211026173943.6829-21-s.shtylyov@omp.ru (mailing list archive)
State New, archived
Headers show
Series [v2,01/22] usb: host: ehci-exynos: deny IRQ0 | expand

Commit Message

Sergey Shtylyov Oct. 26, 2021, 5:39 p.m. UTC
If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/xhci-mtk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Chunfeng Yun (云春峰) Oct. 27, 2021, 8:54 a.m. UTC | #1
On Tue, 2021-10-26 at 20:39 +0300, Sergey Shtylyov wrote:
> If platform_get_irq() returns IRQ0 (considered invalid according to
> Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no
> IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe()
> method...
> 
> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host
> controller")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/xhci-mtk.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index c53f6f276d5c..d2dc8d9863ee 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		return ret;
>  
>  	irq = platform_get_irq_byname_optional(pdev, "host");
> -	if (irq < 0) {
> +	if (irq <= 0) {
>  		if (irq == -EPROBE_DEFER)
>  			return irq;
>  
> @@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		irq = platform_get_irq(pdev, 0);
>  		if (irq < 0)
>  			return irq;
> +		if (!irq)
It is "if (irq <= 0)"?


> +			return -EINVAL;
>  	}
>  
>  	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
Chunfeng Yun (云春峰) Oct. 27, 2021, 9:18 a.m. UTC | #2
On Tue, 2021-10-26 at 20:39 +0300, Sergey Shtylyov wrote:
> If platform_get_irq() returns IRQ0 (considered invalid according to
> Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no
> IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe()
> method...
> 
> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host
> controller")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/xhci-mtk.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index c53f6f276d5c..d2dc8d9863ee 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		return ret;
>  
>  	irq = platform_get_irq_byname_optional(pdev, "host");
> -	if (irq < 0) {
> +	if (irq <= 0) {
>  		if (irq == -EPROBE_DEFER)
>  			return irq;
>  
> @@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		irq = platform_get_irq(pdev, 0);
>  		if (irq < 0)
>  			return irq;
> +		if (!irq)
it's "if (irq <= 0)"?

> +			return -EINVAL;
>  	}
>  
>  	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
Sergey Shtylyov Oct. 27, 2021, 9:25 a.m. UTC | #3
On 27.10.2021 12:18, Chunfeng Yun wrote:

>> If platform_get_irq() returns IRQ0 (considered invalid according to
>> Linus)
>> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no
>> IRQ
>> at all. Deny IRQ0 right away, returning -EINVAL from the probe()
>> method...
>>
>> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host
>> controller")
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>> ---
>>   drivers/usb/host/xhci-mtk.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
>> mtk.c
>> index c53f6f276d5c..d2dc8d9863ee 100644
>> --- a/drivers/usb/host/xhci-mtk.c
>> +++ b/drivers/usb/host/xhci-mtk.c
>> @@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device
>> *pdev)
>>   		return ret;
>>   
>>   	irq = platform_get_irq_byname_optional(pdev, "host");
>> -	if (irq < 0) {
>> +	if (irq <= 0) {
>>   		if (irq == -EPROBE_DEFER)
>>   			return irq;
>>   
>> @@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device
>> *pdev)
>>   		irq = platform_get_irq(pdev, 0);
>>   		if (irq < 0)
>>   			return irq;
>> +		if (!irq)
> it's "if (irq <= 0)"?

    No, if (irq == 0).

>> +			return -EINVAL;
>>   	}
>>   
>>   	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");

MBR, Sergey
Chunfeng Yun (云春峰) Oct. 27, 2021, 9:35 a.m. UTC | #4
On Wed, 2021-10-27 at 12:25 +0300, Sergey Shtylyov wrote:
> On 27.10.2021 12:18, Chunfeng Yun wrote:
> 
> > > If platform_get_irq() returns IRQ0 (considered invalid according
> > > to
> > > Linus)
> > > the driver blithely passes it to usb_add_hcd() that treats IRQ0
> > > as no
> > > IRQ
> > > at all. Deny IRQ0 right away, returning -EINVAL from the probe()
> > > method...
> > > 
> > > Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host
> > > controller")
> > > Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> > > ---
> > >   drivers/usb/host/xhci-mtk.c | 4 +++-
> > >   1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> > > mtk.c
> > > index c53f6f276d5c..d2dc8d9863ee 100644
> > > --- a/drivers/usb/host/xhci-mtk.c
> > > +++ b/drivers/usb/host/xhci-mtk.c
> > > @@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct
> > > platform_device
> > > *pdev)
> > >   		return ret;
> > >   
> > >   	irq = platform_get_irq_byname_optional(pdev, "host");
> > > -	if (irq < 0) {
> > > +	if (irq <= 0) {
> > >   		if (irq == -EPROBE_DEFER)
> > >   			return irq;
> > >   
> > > @@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct
> > > platform_device
> > > *pdev)
> > >   		irq = platform_get_irq(pdev, 0);
Here, irq is updated again

> > >   		if (irq < 0)
> > >   			return irq;
> > > +		if (!irq)
> > 
> > it's "if (irq <= 0)"?
> 
>     No, if (irq == 0).
> 
> > > +			return -EINVAL;
add "else if (irq < 0), return irq;"?  but not -EINVAL only, this may
drop EPROBE_DEFER

> > >   	}
> > >   
> > >   	wakeup_irq = platform_get_irq_byname_optional(pdev,
> > > "wakeup");
> 
> MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c53f6f276d5c..d2dc8d9863ee 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -495,7 +495,7 @@  static int xhci_mtk_probe(struct platform_device *pdev)
 		return ret;
 
 	irq = platform_get_irq_byname_optional(pdev, "host");
-	if (irq < 0) {
+	if (irq <= 0) {
 		if (irq == -EPROBE_DEFER)
 			return irq;
 
@@ -503,6 +503,8 @@  static int xhci_mtk_probe(struct platform_device *pdev)
 		irq = platform_get_irq(pdev, 0);
 		if (irq < 0)
 			return irq;
+		if (!irq)
+			return -EINVAL;
 	}
 
 	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");