From 8f39f442c9e3d5fa6a0f1f3206c9c96d82544dfb Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 25 Aug 2013 08:42:50 +0000 Subject: [PATCH] Bugfix: The endpoint profile should only be checked in device mode when allocating USB transfers and not in host mode. Reported by: George Mitchell --- sys/dev/usb/controller/dwc_otg.c | 22 +++++++++++++--------- sys/dev/usb/controller/musb_otg.c | 16 +++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index d08b3d90c941..7c3b881bafd6 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -3968,7 +3968,6 @@ dwc_otg_roothub_exec(struct usb_device *udev, static void dwc_otg_xfer_setup(struct usb_setup_params *parm) { - const struct usb_hw_ep_profile *pf; struct usb_xfer *xfer; void *last_obj; uint32_t ntd; @@ -4011,16 +4010,21 @@ dwc_otg_xfer_setup(struct usb_setup_params *parm) */ last_obj = NULL; - /* - * get profile stuff - */ ep_no = xfer->endpointno & UE_ADDR; - dwc_otg_get_hw_ep_profile(parm->udev, &pf, ep_no); - if (pf == NULL) { - /* should not happen */ - parm->err = USB_ERR_INVAL; - return; + /* + * Check for a valid endpoint profile in USB device mode: + */ + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { + const struct usb_hw_ep_profile *pf; + + dwc_otg_get_hw_ep_profile(parm->udev, &pf, ep_no); + + if (pf == NULL) { + /* should not happen */ + parm->err = USB_ERR_INVAL; + return; + } } /* align data */ diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c index 5113d7ac9bc0..9b2974f267cc 100644 --- a/sys/dev/usb/controller/musb_otg.c +++ b/sys/dev/usb/controller/musb_otg.c @@ -4026,7 +4026,6 @@ musbotg_roothub_exec(struct usb_device *udev, static void musbotg_xfer_setup(struct usb_setup_params *parm) { - const struct usb_hw_ep_profile *pf; struct musbotg_softc *sc; struct usb_xfer *xfer; void *last_obj; @@ -4088,12 +4087,14 @@ musbotg_xfer_setup(struct usb_setup_params *parm) */ last_obj = NULL; - /* - * get profile stuff - */ - if (ntd) { + ep_no = xfer->endpointno & UE_ADDR; + + /* + * Check for a valid endpoint profile in USB device mode: + */ + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { + const struct usb_hw_ep_profile *pf; - ep_no = xfer->endpointno & UE_ADDR; musbotg_get_hw_ep_profile(parm->udev, &pf, ep_no); if (pf == NULL) { @@ -4101,9 +4102,6 @@ musbotg_xfer_setup(struct usb_setup_params *parm) parm->err = USB_ERR_INVAL; return; } - } else { - ep_no = 0; - pf = NULL; } /* align data */