public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests
@ 2023-07-13  8:14 Pawel Laszczak
  2023-07-14  2:14 ` Peter Chen
  2023-08-25  1:10 ` Peter Chen
  0 siblings, 2 replies; 6+ messages in thread
From: Pawel Laszczak @ 2023-07-13  8:14 UTC (permalink / raw)
  To: peter.chen; +Cc: gregkh, linux-usb, linux-kernel, Pawel Laszczak, stable

Gadget ACM while unloading module try to dequeue not queued usb
request which causes the kernel to crash.
Patch adds extra condition to check whether usb request is processed
by CDNSP driver.

cc: <stable@vger.kernel.org>
Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/cdnsp-gadget.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
index fff9ec9c391f..3a30c2af0c00 100644
--- a/drivers/usb/cdns3/cdnsp-gadget.c
+++ b/drivers/usb/cdns3/cdnsp-gadget.c
@@ -1125,6 +1125,9 @@ static int cdnsp_gadget_ep_dequeue(struct usb_ep *ep,
 	unsigned long flags;
 	int ret;

+	if (request->status != -EINPROGRESS)
+		return 0;
+
 	if (!pep->endpoint.desc) {
 		dev_err(pdev->dev,
 			"%s: can't dequeue to disabled endpoint\n",
-- 
2.37.2


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

* Re: [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests
  2023-07-13  8:14 [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests Pawel Laszczak
@ 2023-07-14  2:14 ` Peter Chen
  2023-07-14  7:19   ` Pawel Laszczak
  2023-08-25  1:10 ` Peter Chen
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Chen @ 2023-07-14  2:14 UTC (permalink / raw)
  To: Pawel Laszczak; +Cc: gregkh, linux-usb, linux-kernel, stable

On 23-07-13 04:14:29, Pawel Laszczak wrote:
> Gadget ACM while unloading module try to dequeue not queued usb
> request which causes the kernel to crash.
> Patch adds extra condition to check whether usb request is processed
> by CDNSP driver.
> 

Why ACM does that?

> cc: <stable@vger.kernel.org>
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---
>  drivers/usb/cdns3/cdnsp-gadget.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
> index fff9ec9c391f..3a30c2af0c00 100644
> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> @@ -1125,6 +1125,9 @@ static int cdnsp_gadget_ep_dequeue(struct usb_ep *ep,
>  	unsigned long flags;
>  	int ret;
> 
> +	if (request->status != -EINPROGRESS)
> +		return 0;
> +

Why not you use pending list which used at cdnsp_ep_enqueue to do this?


>  	if (!pep->endpoint.desc) {
>  		dev_err(pdev->dev,
>  			"%s: can't dequeue to disabled endpoint\n",
> -- 
> 2.37.2
> 

-- 

Thanks,
Peter Chen

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

* RE: [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests
  2023-07-14  2:14 ` Peter Chen
@ 2023-07-14  7:19   ` Pawel Laszczak
  2023-07-16 11:55     ` Peter Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Pawel Laszczak @ 2023-07-14  7:19 UTC (permalink / raw)
  To: Peter Chen
  Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org

>
>On 23-07-13 04:14:29, Pawel Laszczak wrote:
>> Gadget ACM while unloading module try to dequeue not queued usb
>> request which causes the kernel to crash.
>> Patch adds extra condition to check whether usb request is processed
>> by CDNSP driver.
>>
>
>Why ACM does that?
>
>> cc: <stable@vger.kernel.org>
>> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence
>> USBSSP DRD Driver")
>> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>> ---
>>  drivers/usb/cdns3/cdnsp-gadget.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c
>> b/drivers/usb/cdns3/cdnsp-gadget.c
>> index fff9ec9c391f..3a30c2af0c00 100644
>> --- a/drivers/usb/cdns3/cdnsp-gadget.c
>> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
>> @@ -1125,6 +1125,9 @@ static int cdnsp_gadget_ep_dequeue(struct
>usb_ep *ep,
>>  	unsigned long flags;
>>  	int ret;
>>
>> +	if (request->status != -EINPROGRESS)
>> +		return 0;
>> +
>
>Why not you use pending list which used at cdnsp_ep_enqueue to do this?

It's just simpler and faster way - no other reasons. 

Thank,
Pawel

>
>
>>  	if (!pep->endpoint.desc) {
>>  		dev_err(pdev->dev,
>>  			"%s: can't dequeue to disabled endpoint\n",
>> --
>> 2.37.2
>>
>
>--
>
>Thanks,
>Peter Chen

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

* Re: [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests
  2023-07-14  7:19   ` Pawel Laszczak
@ 2023-07-16 11:55     ` Peter Chen
  2023-08-17  9:10       ` Pawel Laszczak
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Chen @ 2023-07-16 11:55 UTC (permalink / raw)
  To: Pawel Laszczak
  Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org

On 23-07-14 07:19:21, Pawel Laszczak wrote:
> >
> >On 23-07-13 04:14:29, Pawel Laszczak wrote:
> >> Gadget ACM while unloading module try to dequeue not queued usb
> >> request which causes the kernel to crash.
> >> Patch adds extra condition to check whether usb request is processed
> >> by CDNSP driver.
> >>
> >
> >Why ACM does that?

Would you please explain which situation triggers it?

> >
> >> cc: <stable@vger.kernel.org>
> >> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence
> >> USBSSP DRD Driver")
> >> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> >> ---
> >>  drivers/usb/cdns3/cdnsp-gadget.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c
> >> b/drivers/usb/cdns3/cdnsp-gadget.c
> >> index fff9ec9c391f..3a30c2af0c00 100644
> >> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> >> @@ -1125,6 +1125,9 @@ static int cdnsp_gadget_ep_dequeue(struct
> >usb_ep *ep,
> >>  	unsigned long flags;
> >>  	int ret;
> >>
> >> +	if (request->status != -EINPROGRESS)
> >> +		return 0;
> >> +
> >
> >Why not you use pending list which used at cdnsp_ep_enqueue to do this?
> 
> It's just simpler and faster way - no other reasons. 

Okay, get it.

-- 

Thanks,
Peter Chen

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

* RE: [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests
  2023-07-16 11:55     ` Peter Chen
@ 2023-08-17  9:10       ` Pawel Laszczak
  0 siblings, 0 replies; 6+ messages in thread
From: Pawel Laszczak @ 2023-08-17  9:10 UTC (permalink / raw)
  To: Peter Chen
  Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org


>> >
>> >On 23-07-13 04:14:29, Pawel Laszczak wrote:
>> >> Gadget ACM while unloading module try to dequeue not queued usb
>> >> request which causes the kernel to crash.
>> >> Patch adds extra condition to check whether usb request is
>> >> processed by CDNSP driver.
>> >>
>> >
>> >Why ACM does that?
>
>Would you please explain which situation triggers it?

The sequence to trigger is simple:
- Load modules (u_serial, f_acm and udc driver)
- unload module

In my case the plug is attached to host.

While unloading in the gs_console_disconnect function is involved
which try dequeue the usb_request not queued.

Without fix controller driver during dequeuing trees to make operation
on not initialized field which causes the kernel to crash.

Regards,
Pawel

>> >
>> >> cc: <stable@vger.kernel.org>
>> >> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence
>> >> USBSSP DRD Driver")
>> >> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>> >> ---
>> >>  drivers/usb/cdns3/cdnsp-gadget.c | 3 +++
>> >>  1 file changed, 3 insertions(+)
>> >>
>> >> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c
>> >> b/drivers/usb/cdns3/cdnsp-gadget.c
>> >> index fff9ec9c391f..3a30c2af0c00 100644
>> >> --- a/drivers/usb/cdns3/cdnsp-gadget.c
>> >> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
>> >> @@ -1125,6 +1125,9 @@ static int cdnsp_gadget_ep_dequeue(struct
>> >usb_ep *ep,
>> >>  	unsigned long flags;
>> >>  	int ret;
>> >>
>> >> +	if (request->status != -EINPROGRESS)
>> >> +		return 0;
>> >> +
>> >
>> >Why not you use pending list which used at cdnsp_ep_enqueue to do this?
>>
>> It's just simpler and faster way - no other reasons.
>
>Okay, get it.
>
>--
>
>Thanks,
>Peter Chen

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

* Re: [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests
  2023-07-13  8:14 [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests Pawel Laszczak
  2023-07-14  2:14 ` Peter Chen
@ 2023-08-25  1:10 ` Peter Chen
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Chen @ 2023-08-25  1:10 UTC (permalink / raw)
  To: Pawel Laszczak; +Cc: peter.chen, gregkh, linux-usb, linux-kernel, stable

On Thu, Jul 13, 2023 at 4:14 PM Pawel Laszczak <pawell@cadence.com> wrote:
>
> Gadget ACM while unloading module try to dequeue not queued usb
> request which causes the kernel to crash.
> Patch adds extra condition to check whether usb request is processed
> by CDNSP driver.
>
> cc: <stable@vger.kernel.org>
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver")
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---

Acked-by: Peter Chen <peter.chen@kernel.org>

Peter

>  drivers/usb/cdns3/cdnsp-gadget.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
> index fff9ec9c391f..3a30c2af0c00 100644
> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> @@ -1125,6 +1125,9 @@ static int cdnsp_gadget_ep_dequeue(struct usb_ep *ep,
>         unsigned long flags;
>         int ret;
>
> +       if (request->status != -EINPROGRESS)
> +               return 0;
> +
>         if (!pep->endpoint.desc) {
>                 dev_err(pdev->dev,
>                         "%s: can't dequeue to disabled endpoint\n",
> --
> 2.37.2
>

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

end of thread, other threads:[~2023-08-25  1:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-13  8:14 [PATCH] usb: cdnsp: Fixes issue with dequeuing not queued requests Pawel Laszczak
2023-07-14  2:14 ` Peter Chen
2023-07-14  7:19   ` Pawel Laszczak
2023-07-16 11:55     ` Peter Chen
2023-08-17  9:10       ` Pawel Laszczak
2023-08-25  1:10 ` Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox