diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 88e894dd3568..88621fd93da3 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1368,7 +1368,7 @@ struct hfa384x { }; -void hfa384x_create(struct hfa384x *hw, struct usb_device *usb); +int hfa384x_create(struct hfa384x *hw, struct usb_device *usb); void hfa384x_destroy(struct hfa384x *hw); int hfa384x_corereset(struct hfa384x *hw, int holdtime, int settletime, diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index fa1bf8b069fd..cd494968905c 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -406,7 +406,6 @@ static int submit_tx_urb(struct hfa384x *hw, struct urb *tx_urb, gfp_t memflags) } } } - return result; } @@ -514,7 +513,8 @@ static void hfa384x_usb_defer(struct work_struct *data) * membase memory base address for register access * * Returns: - * nothing + * 0 success + * <0 invalid endpoint * * Side effects: * @@ -522,11 +522,25 @@ static void hfa384x_usb_defer(struct work_struct *data) * process *---------------------------------------------------------------- */ -void hfa384x_create(struct hfa384x *hw, struct usb_device *usb) +int hfa384x_create(struct hfa384x *hw, struct usb_device *usb) { + const struct usb_host_endpoint *ep; + memset(hw, 0, sizeof(*hw)); hw->usb = usb; + ep = usb->ep_in[1]; + if (!ep) + return -EINVAL; + if (usb_endpoint_type(&ep->desc) != USB_ENDPOINT_XFER_BULK) + return -EINVAL; + + ep = usb->ep_out[2]; + if (!ep) + return -EINVAL; + if (usb_endpoint_type(&ep->desc) != USB_ENDPOINT_XFER_BULK) + return -EINVAL; + /* set up the endpoints */ hw->endp_in = usb_rcvbulkpipe(usb, 1); hw->endp_out = usb_sndbulkpipe(usb, 2); @@ -566,6 +580,7 @@ void hfa384x_create(struct hfa384x *hw, struct usb_device *usb) INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer); timer_setup(&hw->commsqual_timer, prism2sta_commsqual_timer, 0); + return 0; } /*---------------------------------------------------------------- diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 4689b2170e4f..39f3366eaa36 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -82,7 +82,9 @@ static int prism2sta_probe_usb(struct usb_interface *interface, } /* Initialize the hw data */ - hfa384x_create(hw, dev); + result = hfa384x_create(hw, dev); + if (result) + goto failed; hw->wlandev = wlandev; /* Register the wlandev, this gets us a name and registers the