All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: qcom: Check for null irq pointer
@ 2021-12-20 10:15 Jiasheng Jiang
  2021-12-20 10:44 ` Greg KH
  2021-12-20 11:25 ` Sergey Shtylyov
  0 siblings, 2 replies; 6+ messages in thread
From: Jiasheng Jiang @ 2021-12-20 10:15 UTC (permalink / raw)
  To: agross, bjorn.andersson, balbi, gregkh, p.zabel
  Cc: linux-arm-msm, linux-usb, linux-kernel, Jiasheng Jiang

The return value of platform_get_irq() needs to be checked.
To avoid use of null pointer in case that there is no irq.

Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/usb/dwc3/dwc3-qcom.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 49e6ca94486d..f04fb3f2fb85 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -614,6 +614,11 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
 		qcom->acpi_pdata->dwc3_core_base_size;
 
 	irq = platform_get_irq(pdev_irq, 0);
+	if (!irq) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	child_res[1].flags = IORESOURCE_IRQ;
 	child_res[1].start = child_res[1].end = irq;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Check for null irq pointer
  2021-12-20 10:15 [PATCH] usb: dwc3: qcom: Check for null irq pointer Jiasheng Jiang
@ 2021-12-20 10:44 ` Greg KH
  2021-12-20 11:25 ` Sergey Shtylyov
  1 sibling, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-12-20 10:44 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: agross, bjorn.andersson, balbi, p.zabel, linux-arm-msm,
	linux-usb, linux-kernel

On Mon, Dec 20, 2021 at 06:15:20PM +0800, Jiasheng Jiang wrote:
> The return value of platform_get_irq() needs to be checked.
> To avoid use of null pointer in case that there is no irq.
> 
> Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 49e6ca94486d..f04fb3f2fb85 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -614,6 +614,11 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
>  		qcom->acpi_pdata->dwc3_core_base_size;
>  
>  	irq = platform_get_irq(pdev_irq, 0);
> +	if (!irq) {
> +		ret = -EINVAL;

That is NOT the proper way to check the return value of this function
call.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Check for null irq pointer
  2021-12-20 10:15 [PATCH] usb: dwc3: qcom: Check for null irq pointer Jiasheng Jiang
  2021-12-20 10:44 ` Greg KH
@ 2021-12-20 11:25 ` Sergey Shtylyov
  2021-12-20 11:48   ` Sergey Shtylyov
  1 sibling, 1 reply; 6+ messages in thread
From: Sergey Shtylyov @ 2021-12-20 11:25 UTC (permalink / raw)
  To: Jiasheng Jiang, agross, bjorn.andersson, balbi, gregkh, p.zabel
  Cc: linux-arm-msm, linux-usb, linux-kernel

On 20.12.2021 13:15, Jiasheng Jiang wrote:

> The return value of platform_get_irq() needs to be checked.
> To avoid use of null pointer

   What null pointer, could you please clarify?

in case that there is no irq.
> 
> Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   drivers/usb/dwc3/dwc3-qcom.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 49e6ca94486d..f04fb3f2fb85 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -614,6 +614,11 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
>   		qcom->acpi_pdata->dwc3_core_base_size;
>   
>   	irq = platform_get_irq(pdev_irq, 0);
> +	if (!irq) {

    This is totally wrong! That function returns negative error codes in case 
of failure.

> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
>   	child_res[1].flags = IORESOURCE_IRQ;
>   	child_res[1].start = child_res[1].end = irq;

MBR, Sergey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Check for null irq pointer
  2021-12-20 11:25 ` Sergey Shtylyov
@ 2021-12-20 11:48   ` Sergey Shtylyov
  2021-12-20 12:14     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Sergey Shtylyov @ 2021-12-20 11:48 UTC (permalink / raw)
  To: Jiasheng Jiang, agross, bjorn.andersson, balbi, gregkh, p.zabel
  Cc: linux-arm-msm, linux-usb, linux-kernel

On 20.12.2021 14:25, Sergey Shtylyov wrote:

>> The return value of platform_get_irq() needs to be checked.
>> To avoid use of null pointer
> 
>    What null pointer, could you please clarify?
> 
>> in case that there is no irq.
>>
>> Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
>> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

    This has already been addressed by this (yet unmerged) patch:

https://marc.info/?l=linux-usb&m=162854066430255

MBR, Sergey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Check for null irq pointer
  2021-12-20 11:48   ` Sergey Shtylyov
@ 2021-12-20 12:14     ` Greg KH
  2021-12-20 12:22       ` Sergey Shtylyov
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2021-12-20 12:14 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: Jiasheng Jiang, agross, bjorn.andersson, balbi, p.zabel,
	linux-arm-msm, linux-usb, linux-kernel

On Mon, Dec 20, 2021 at 02:48:12PM +0300, Sergey Shtylyov wrote:
> On 20.12.2021 14:25, Sergey Shtylyov wrote:
> 
> > > The return value of platform_get_irq() needs to be checked.
> > > To avoid use of null pointer
> > 
> >    What null pointer, could you please clarify?
> > 
> > > in case that there is no irq.
> > > 
> > > Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
> > > Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> 
>    This has already been addressed by this (yet unmerged) patch:
> 
> https://marc.info/?l=linux-usb&m=162854066430255

Why not wait until that patch is actually merged?  Otherwise all of this
work is moot.

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Check for null irq pointer
  2021-12-20 12:14     ` Greg KH
@ 2021-12-20 12:22       ` Sergey Shtylyov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Shtylyov @ 2021-12-20 12:22 UTC (permalink / raw)
  To: Greg KH
  Cc: Jiasheng Jiang, agross, bjorn.andersson, balbi, p.zabel,
	linux-arm-msm, linux-usb, linux-kernel

On 20.12.2021 15:14, Greg KH wrote:

[...]
>>>> The return value of platform_get_irq() needs to be checked.
>>>> To avoid use of null pointer
>>>
>>>     What null pointer, could you please clarify?
>>>
>>>> in case that there is no irq.
>>>>
>>>> Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
>>>> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
>>
>>     This has already been addressed by this (yet unmerged) patch:
>>
>> https://marc.info/?l=linux-usb&m=162854066430255

> Why not wait until that patch is actually merged?  Otherwise all of this
> work is moot.

    Wait, it has been merged back in August. Then this patch is just 
outdated... :-)

> greg k-h

MBR, Sergey

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-20 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 10:15 [PATCH] usb: dwc3: qcom: Check for null irq pointer Jiasheng Jiang
2021-12-20 10:44 ` Greg KH
2021-12-20 11:25 ` Sergey Shtylyov
2021-12-20 11:48   ` Sergey Shtylyov
2021-12-20 12:14     ` Greg KH
2021-12-20 12:22       ` Sergey Shtylyov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.