USB: Add initialization checks to Pipe usages of Device.

Complements the ones added earlier to the module itself.
Should fix the panic portion of #15115.
This commit is contained in:
Augustin Cavalier 2019-06-17 19:14:29 -04:00
parent ceec04eaf5
commit 4f8124c5e3

View File

@ -82,7 +82,11 @@ status_t
Pipe::SetFeature(uint16 selector)
{
TRACE("set feature %u\n", selector);
return ((Device *)Parent())->DefaultPipe()->SendRequest(
Device *device = (Device *)Parent();
if (device->InitCheck() != B_OK)
return B_NO_INIT;
return device->DefaultPipe()->SendRequest(
USB_REQTYPE_STANDARD | USB_REQTYPE_ENDPOINT_OUT,
USB_REQUEST_SET_FEATURE,
selector,
@ -98,12 +102,16 @@ Pipe::SetFeature(uint16 selector)
status_t
Pipe::ClearFeature(uint16 selector)
{
Device *device = (Device *)Parent();
if (device->InitCheck() != B_OK)
return B_NO_INIT;
// clearing a stalled condition resets the data toggle
if (selector == USB_FEATURE_ENDPOINT_HALT)
SetDataToggle(false);
TRACE("clear feature %u\n", selector);
return ((Device *)Parent())->DefaultPipe()->SendRequest(
return device->DefaultPipe()->SendRequest(
USB_REQTYPE_STANDARD | USB_REQTYPE_ENDPOINT_OUT,
USB_REQUEST_CLEAR_FEATURE,
selector,
@ -120,7 +128,11 @@ status_t
Pipe::GetStatus(uint16 *status)
{
TRACE("get status\n");
return ((Device *)Parent())->DefaultPipe()->SendRequest(
Device *device = (Device *)Parent();
if (device->InitCheck() != B_OK)
return B_NO_INIT;
return device->DefaultPipe()->SendRequest(
USB_REQTYPE_STANDARD | USB_REQTYPE_ENDPOINT_IN,
USB_REQUEST_GET_STATUS,
0,