Re: UDC ep0 desc or no desc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 23 Jun 2018, Benjamin Herrenschmidt wrote:

> Hi folks !
> 
> I noticed some UDC drivers setup a "desc" pointer for ep0.desc for the
> driver, some don't.
> 
> Is it officially needed ?

No, it isn't.  The only "core" routine that requires a desc pointer in 
the endpoint structure is usb_ep_enable, and that routine explicitly 
says it may not be called for ep0.

> Additionally some UCDs NULL out the desc pointer in ep_disable, is that
> also a requirement ?

No.  A disabled endpoint doesn't have any requirements on its 
descriptor or lack thereof.

> I somewhat fear that if somebody calls stuff like usb_ep_align() on ep0
> it will crash without a valid desc pointer...

That would be a pretty strange thing to do.  I'd say it's not worth 
worrying about until somebody makes that mistake.

> That leads me to wonder, should we sprinkle null checks (and maybe
> WARN_ON_ONCE) on some of those accessors to catch those cases ?

I think segmentation faults will do a good job of catching them.  :-)

Alan Stern

> I notices a few reports (and I'm about to debug one with my own UDC,
> aspeed vhub when I'm back at work on Monday, with HID) where we get a
> crash with a NULL dereference and while I don't know for sure yet
> that's the problem, the fact that EP0 has a NULL desc with most UDCs
> and that we clear the desc on EP disablement somewhat tickles me the
> wrong way...
> 
> Cheers,
> Ben.
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux