diff mbox series

usb: gadget: f_sourcesink: Fix isoc transfer for USB_SPEED_SUPER_PLUS

Message ID 1642764684-26060-1-git-send-email-quic_pkondeti@quicinc.com (mailing list archive)
State Superseded
Headers show
Series usb: gadget: f_sourcesink: Fix isoc transfer for USB_SPEED_SUPER_PLUS | expand

Commit Message

Pavan Kondeti Jan. 21, 2022, 11:31 a.m. UTC
Currently when gadget enumerates in super speed plus, the isoc
endpoint request buffer size is not calculated correctly. Fix
this by checking the gadget speed against USB_SPEED_SUPER_PLUS
and update the request buffer size.

Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
---
 drivers/usb/gadget/function/f_sourcesink.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Greg Kroah-Hartman Jan. 21, 2022, 2:31 p.m. UTC | #1
On Fri, Jan 21, 2022 at 05:01:24PM +0530, Pavankumar Kondeti wrote:
> Currently when gadget enumerates in super speed plus, the isoc
> endpoint request buffer size is not calculated correctly. Fix
> this by checking the gadget speed against USB_SPEED_SUPER_PLUS
> and update the request buffer size.
> 
> Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>

What commit id does this fix?

thanks,

greg k-h
Alan Stern Jan. 21, 2022, 3:09 p.m. UTC | #2
On Fri, Jan 21, 2022 at 05:01:24PM +0530, Pavankumar Kondeti wrote:
> Currently when gadget enumerates in super speed plus, the isoc
> endpoint request buffer size is not calculated correctly. Fix
> this by checking the gadget speed against USB_SPEED_SUPER_PLUS
> and update the request buffer size.
> 
> Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
> ---
>  drivers/usb/gadget/function/f_sourcesink.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
> index 1abf08e..0a423ba 100644
> --- a/drivers/usb/gadget/function/f_sourcesink.c
> +++ b/drivers/usb/gadget/function/f_sourcesink.c
> @@ -584,6 +584,8 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
>  
>  	if (is_iso) {
>  		switch (speed) {
> +		case USB_SPEED_SUPER_PLUS:
> +			fallthrough;

There's no need for this "fallthough" line.  You're allowed to have 
multiple case labels for a single block of code.

Alan Stern

>  		case USB_SPEED_SUPER:
>  			size = ss->isoc_maxpacket *
>  					(ss->isoc_mult + 1) *
> -- 
> 2.7.4
>
Pavan Kondeti Jan. 22, 2022, 2:54 a.m. UTC | #3
Hi Alan,

On Fri, Jan 21, 2022 at 10:09:00AM -0500, Alan Stern wrote:
> On Fri, Jan 21, 2022 at 05:01:24PM +0530, Pavankumar Kondeti wrote:
> > Currently when gadget enumerates in super speed plus, the isoc
> > endpoint request buffer size is not calculated correctly. Fix
> > this by checking the gadget speed against USB_SPEED_SUPER_PLUS
> > and update the request buffer size.
> > 
> > Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
> > ---
> >  drivers/usb/gadget/function/f_sourcesink.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
> > index 1abf08e..0a423ba 100644
> > --- a/drivers/usb/gadget/function/f_sourcesink.c
> > +++ b/drivers/usb/gadget/function/f_sourcesink.c
> > @@ -584,6 +584,8 @@ static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
> >  
> >  	if (is_iso) {
> >  		switch (speed) {
> > +		case USB_SPEED_SUPER_PLUS:
> > +			fallthrough;
> 
> There's no need for this "fallthough" line.  You're allowed to have 
> multiple case labels for a single block of code.
> 
Thanks for the review. I will incorporate your suggestion in v2.

Thanks,
Pavan
Pavan Kondeti Jan. 22, 2022, 2:56 a.m. UTC | #4
Hi Greg,

On Fri, Jan 21, 2022 at 03:31:12PM +0100, Greg Kroah-Hartman wrote:
> On Fri, Jan 21, 2022 at 05:01:24PM +0530, Pavankumar Kondeti wrote:
> > Currently when gadget enumerates in super speed plus, the isoc
> > endpoint request buffer size is not calculated correctly. Fix
> > this by checking the gadget speed against USB_SPEED_SUPER_PLUS
> > and update the request buffer size.
> > 
> > Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
> 
> What commit id does this fix?
> 
I see that the issue is present since the super speed plus support
is added to this driver. I will add the below commit in the Fixes
tag and send the v2.

commit 90c4d05780d47e14a50e11a7f17373104cd47d25
Author: Maciej Żenczykowski <maze@google.com>
Date:   Mon Jun 7 21:41:41 2021 -0700

    usb: fix various gadgets null ptr deref on 10gbps cabling.

    This avoids a null pointer dereference in
    f_{ecm,eem,hid,loopback,printer,rndis,serial,sourcesink,subset,tcm}
    by simply reusing the 5gbps config for 10gbps.

Thanks,
Pavan
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index 1abf08e..0a423ba 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -584,6 +584,8 @@  static int source_sink_start_ep(struct f_sourcesink *ss, bool is_in,
 
 	if (is_iso) {
 		switch (speed) {
+		case USB_SPEED_SUPER_PLUS:
+			fallthrough;
 		case USB_SPEED_SUPER:
 			size = ss->isoc_maxpacket *
 					(ss->isoc_mult + 1) *