All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: fusb300_udc: free irq on the error path in fusb300_probe()
@ 2022-11-20  6:12 Gaosheng Cui
  2022-11-20 11:01 ` Dongliang Mu
  0 siblings, 1 reply; 3+ messages in thread
From: Gaosheng Cui @ 2022-11-20  6:12 UTC (permalink / raw)
  To: gregkh, cuigaosheng1, yhchen; +Cc: linux-usb

When request_irq(ires1->start) failed in w5300_hw_probe(), irq ires->start
has not been freed, and on the clean_up3 error path, we need to free
ires1->start irq, too. Fix it.

Fixes: 0fe6f1d1f612 ("usb: udc: add Faraday fusb300 driver")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 drivers/usb/gadget/udc/fusb300_udc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c
index 9af8b415f303..c66a59c15003 100644
--- a/drivers/usb/gadget/udc/fusb300_udc.c
+++ b/drivers/usb/gadget/udc/fusb300_udc.c
@@ -1432,7 +1432,7 @@ static int fusb300_probe(struct platform_device *pdev)
 			IRQF_SHARED, udc_name, fusb300);
 	if (ret < 0) {
 		pr_err("request_irq1 error (%d)\n", ret);
-		goto clean_up;
+		goto clean_up2;
 	}
 
 	INIT_LIST_HEAD(&fusb300->gadget.ep_list);
@@ -1487,8 +1487,9 @@ static int fusb300_probe(struct platform_device *pdev)
 	fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
 
 clean_up3:
+	free_irq(ires1->start, fusb300);
+clean_up2:
 	free_irq(ires->start, fusb300);
-
 clean_up:
 	if (fusb300) {
 		if (fusb300->ep0_req)
-- 
2.25.1


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

* Re: [PATCH] usb: gadget: fusb300_udc: free irq on the error path in fusb300_probe()
  2022-11-20  6:12 [PATCH] usb: gadget: fusb300_udc: free irq on the error path in fusb300_probe() Gaosheng Cui
@ 2022-11-20 11:01 ` Dongliang Mu
  2022-11-21  1:49   ` cuigaosheng
  0 siblings, 1 reply; 3+ messages in thread
From: Dongliang Mu @ 2022-11-20 11:01 UTC (permalink / raw)
  To: Gaosheng Cui; +Cc: gregkh, yhchen, linux-usb

On Sun, Nov 20, 2022 at 2:25 PM Gaosheng Cui <cuigaosheng1@huawei.com> wrote:
>
> When request_irq(ires1->start) failed in w5300_hw_probe(), irq ires->start
> has not been freed, and on the clean_up3 error path, we need to free
> ires1->start irq, too. Fix it.
>
> Fixes: 0fe6f1d1f612 ("usb: udc: add Faraday fusb300 driver")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>  drivers/usb/gadget/udc/fusb300_udc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c
> index 9af8b415f303..c66a59c15003 100644
> --- a/drivers/usb/gadget/udc/fusb300_udc.c
> +++ b/drivers/usb/gadget/udc/fusb300_udc.c
> @@ -1432,7 +1432,7 @@ static int fusb300_probe(struct platform_device *pdev)
>                         IRQF_SHARED, udc_name, fusb300);
>         if (ret < 0) {
>                 pr_err("request_irq1 error (%d)\n", ret);
> -               goto clean_up;
> +               goto clean_up2;
>         }
>
>         INIT_LIST_HEAD(&fusb300->gadget.ep_list);
> @@ -1487,8 +1487,9 @@ static int fusb300_probe(struct platform_device *pdev)
>         fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
>
>  clean_up3:
> +       free_irq(ires1->start, fusb300);

Hi Gaosheng,

it seems you need to add the same free_irq in the .remove function.
Refer to the following patch,

--- a/drivers/usb/gadget/udc/fusb300_udc.c
+++ b/drivers/usb/gadget/udc/fusb300_udc.c
@@ -1347,6 +1347,7 @@ static int fusb300_remove(struct platform_device *pdev)
        usb_del_gadget_udc(&fusb300->gadget);
        iounmap(fusb300->reg);
        free_irq(platform_get_irq(pdev, 0), fusb300);
+       free_irq(platform_get_irq(pdev, 1), fusb300);

        fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
        for (i = 0; i < FUSB300_MAX_NUM_EP; i++)

Fix me if I make any mistakes.

> +clean_up2:
>         free_irq(ires->start, fusb300);
> -
>  clean_up:
>         if (fusb300) {
>                 if (fusb300->ep0_req)
> --
> 2.25.1
>

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

* Re: [PATCH] usb: gadget: fusb300_udc: free irq on the error path in fusb300_probe()
  2022-11-20 11:01 ` Dongliang Mu
@ 2022-11-21  1:49   ` cuigaosheng
  0 siblings, 0 replies; 3+ messages in thread
From: cuigaosheng @ 2022-11-21  1:49 UTC (permalink / raw)
  To: Dongliang Mu; +Cc: gregkh, yhchen, linux-usb

> it seems you need to add the same free_irq in the .remove function.
> Refer to the following patch,
>
> --- a/drivers/usb/gadget/udc/fusb300_udc.c
> +++ b/drivers/usb/gadget/udc/fusb300_udc.c
> @@ -1347,6 +1347,7 @@ static int fusb300_remove(struct platform_device *pdev)
>          usb_del_gadget_udc(&fusb300->gadget);
>          iounmap(fusb300->reg);
>          free_irq(platform_get_irq(pdev, 0), fusb300);
> +       free_irq(platform_get_irq(pdev, 1), fusb300);
>
>          fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
>          for (i = 0; i < FUSB300_MAX_NUM_EP; i++)

Thanks for taking time to review this patch, I have made a patch v2 and submit it.

On 2022/11/20 19:01, Dongliang Mu wrote:
> On Sun, Nov 20, 2022 at 2:25 PM Gaosheng Cui <cuigaosheng1@huawei.com> wrote:
>> When request_irq(ires1->start) failed in w5300_hw_probe(), irq ires->start
>> has not been freed, and on the clean_up3 error path, we need to free
>> ires1->start irq, too. Fix it.
>>
>> Fixes: 0fe6f1d1f612 ("usb: udc: add Faraday fusb300 driver")
>> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
>> ---
>>   drivers/usb/gadget/udc/fusb300_udc.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c
>> index 9af8b415f303..c66a59c15003 100644
>> --- a/drivers/usb/gadget/udc/fusb300_udc.c
>> +++ b/drivers/usb/gadget/udc/fusb300_udc.c
>> @@ -1432,7 +1432,7 @@ static int fusb300_probe(struct platform_device *pdev)
>>                          IRQF_SHARED, udc_name, fusb300);
>>          if (ret < 0) {
>>                  pr_err("request_irq1 error (%d)\n", ret);
>> -               goto clean_up;
>> +               goto clean_up2;
>>          }
>>
>>          INIT_LIST_HEAD(&fusb300->gadget.ep_list);
>> @@ -1487,8 +1487,9 @@ static int fusb300_probe(struct platform_device *pdev)
>>          fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
>>
>>   clean_up3:
>> +       free_irq(ires1->start, fusb300);
> Hi Gaosheng,
>
> it seems you need to add the same free_irq in the .remove function.
> Refer to the following patch,
>
> --- a/drivers/usb/gadget/udc/fusb300_udc.c
> +++ b/drivers/usb/gadget/udc/fusb300_udc.c
> @@ -1347,6 +1347,7 @@ static int fusb300_remove(struct platform_device *pdev)
>          usb_del_gadget_udc(&fusb300->gadget);
>          iounmap(fusb300->reg);
>          free_irq(platform_get_irq(pdev, 0), fusb300);
> +       free_irq(platform_get_irq(pdev, 1), fusb300);
>
>          fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);
>          for (i = 0; i < FUSB300_MAX_NUM_EP; i++)
>
> Fix me if I make any mistakes.
>
>> +clean_up2:
>>          free_irq(ires->start, fusb300);
>> -
>>   clean_up:
>>          if (fusb300) {
>>                  if (fusb300->ep0_req)
>> --
>> 2.25.1
>>
> .

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

end of thread, other threads:[~2022-11-21  1:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-20  6:12 [PATCH] usb: gadget: fusb300_udc: free irq on the error path in fusb300_probe() Gaosheng Cui
2022-11-20 11:01 ` Dongliang Mu
2022-11-21  1:49   ` cuigaosheng

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.