diff mbox series

usb: misc: eud: Fix missing IRQ check in eud_probe()

Message ID tencent_C40B301A0F71853A540809BE1BB85AB12D07@qq.com
State New
Headers show
Series usb: misc: eud: Fix missing IRQ check in eud_probe() | expand

Commit Message

Zhang Shurong Aug. 26, 2023, 10:47 a.m. UTC
This func misses checking for platform_get_irq()'s call and may passes the
negative error codes to request_irq(), which takes unsigned IRQ #,
causing it to fail with -EINVAL, overriding an original error code.

Fix this by stop calling request_irq() with invalid IRQ #s.

Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
 drivers/usb/misc/qcom_eud.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Konrad Dybcio Aug. 26, 2023, 10:49 a.m. UTC | #1
On 26.08.2023 12:47, Zhang Shurong wrote:
> This func misses checking for platform_get_irq()'s call and may passes the
> negative error codes to request_irq(), which takes unsigned IRQ #,
> causing it to fail with -EINVAL, overriding an original error code.
> 
> Fix this by stop calling request_irq() with invalid IRQ #s.
> 
> Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
> ---
>  drivers/usb/misc/qcom_eud.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> index 7f371ea1248c..b33c615a2037 100644
> --- a/drivers/usb/misc/qcom_eud.c
> +++ b/drivers/usb/misc/qcom_eud.c
> @@ -204,7 +204,12 @@ static int eud_probe(struct platform_device *pdev)
>  	if (IS_ERR(chip->mode_mgr))
>  		return PTR_ERR(chip->mode_mgr);
>  
> -	chip->irq = platform_get_irq(pdev, 0);
> +	ret = platform_get_irq(pdev, 0);
> +	if (ret < 0)
> +		return ret;
> +
> +	chip->irq = ret;chip->irq = plat..
if (chip->irq < 0)
	return chip->irq

?

Konrad
Zhang Shurong Aug. 26, 2023, 2:17 p.m. UTC | #2
在 2023年8月26日星期六 CST 下午6:49:27,Konrad Dybcio 写道:
> On 26.08.2023 12:47, Zhang Shurong wrote:
> > This func misses checking for platform_get_irq()'s call and may passes the
> > negative error codes to request_irq(), which takes unsigned IRQ #,
> > causing it to fail with -EINVAL, overriding an original error code.
> > 
> > Fix this by stop calling request_irq() with invalid IRQ #s.
> > 
> > Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB
> > Debugger(EUD)") Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
> > ---
> > 
> >  drivers/usb/misc/qcom_eud.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> > index 7f371ea1248c..b33c615a2037 100644
> > --- a/drivers/usb/misc/qcom_eud.c
> > +++ b/drivers/usb/misc/qcom_eud.c
> > @@ -204,7 +204,12 @@ static int eud_probe(struct platform_device *pdev)
> > 
> >  	if (IS_ERR(chip->mode_mgr))
> >  	
> >  		return PTR_ERR(chip->mode_mgr);
> > 
> > -	chip->irq = platform_get_irq(pdev, 0);
> > +	ret = platform_get_irq(pdev, 0);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	chip->irq = ret;chip->irq = plat..
> 
> if (chip->irq < 0)
> 	return chip->irq
> 
> ?
> 
> Konrad
Thank you for your thoughtful response. To clarify, are you suggesting that I 
replace the usage of `ret` with `chip->irq`? If that is the case, I will 
proceed with creating a patch for version 2.
Konrad Dybcio Aug. 28, 2023, 10:58 a.m. UTC | #3
On 26.08.2023 16:17, Zhang Shurong wrote:
> 在 2023年8月26日星期六 CST 下午6:49:27,Konrad Dybcio 写道:
>> On 26.08.2023 12:47, Zhang Shurong wrote:
>>> This func misses checking for platform_get_irq()'s call and may passes the
>>> negative error codes to request_irq(), which takes unsigned IRQ #,
>>> causing it to fail with -EINVAL, overriding an original error code.
>>>
>>> Fix this by stop calling request_irq() with invalid IRQ #s.
>>>
>>> Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB
>>> Debugger(EUD)") Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
>>> ---
>>>
>>>  drivers/usb/misc/qcom_eud.c | 7 ++++++-
>>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
>>> index 7f371ea1248c..b33c615a2037 100644
>>> --- a/drivers/usb/misc/qcom_eud.c
>>> +++ b/drivers/usb/misc/qcom_eud.c
>>> @@ -204,7 +204,12 @@ static int eud_probe(struct platform_device *pdev)
>>>
>>>  	if (IS_ERR(chip->mode_mgr))
>>>  	
>>>  		return PTR_ERR(chip->mode_mgr);
>>>
>>> -	chip->irq = platform_get_irq(pdev, 0);
>>> +	ret = platform_get_irq(pdev, 0);
>>> +	if (ret < 0)
>>> +		return ret;
>>> +
>>> +	chip->irq = ret;chip->irq = plat..
>>
>> if (chip->irq < 0)
>> 	return chip->irq
>>
>> ?
>>
>> Konrad
> Thank you for your thoughtful response. To clarify, are you suggesting that I 
> replace the usage of `ret` with `chip->irq`? If that is the case, I will 
> proceed with creating a patch for version 2.
Yes please

Konrad
diff mbox series

Patch

diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
index 7f371ea1248c..b33c615a2037 100644
--- a/drivers/usb/misc/qcom_eud.c
+++ b/drivers/usb/misc/qcom_eud.c
@@ -204,7 +204,12 @@  static int eud_probe(struct platform_device *pdev)
 	if (IS_ERR(chip->mode_mgr))
 		return PTR_ERR(chip->mode_mgr);
 
-	chip->irq = platform_get_irq(pdev, 0);
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		return ret;
+
+	chip->irq = ret;
+
 	ret = devm_request_threaded_irq(&pdev->dev, chip->irq, handle_eud_irq,
 			handle_eud_irq_thread, IRQF_ONESHOT, NULL, chip);
 	if (ret)