Print this page
9576 hid_attach is missing one mutex_exit in error path
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>


 417          * Make sure that the bInterfaceProtocol only has meaning to
 418          * Boot Interface Subclass.
 419          */
 420         if (hidp->hid_if_descr.bInterfaceSubClass != BOOT_INTERFACE)
 421                 hidp->hid_if_descr.bInterfaceProtocol = NONE_PROTOCOL;
 422         mutex_exit(&hidp->hid_mutex);
 423 
 424         if ((ep_data = usb_lookup_ep_data(dip, dev_data,
 425             hidp->hid_interfaceno, 0, 0,
 426             (uint_t)USB_EP_ATTR_INTR, (uint_t)USB_EP_DIR_IN)) == NULL) {
 427 
 428                 USB_DPRINTF_L2(PRINT_MASK_ATTA, hidp->hid_log_handle,
 429                     "no interrupt IN endpoint found");
 430 
 431                 goto fail;
 432         }
 433 
 434         mutex_enter(&hidp->hid_mutex);
 435         if (usb_ep_xdescr_fill(USB_EP_XDESCR_CURRENT_VERSION, dip, ep_data,
 436             &hidp->hid_ep_intr_xdescr) != USB_SUCCESS) {

 437 
 438                 goto fail;
 439         }
 440 
 441         /*
 442          * Attempt to find the hid descriptor, it could be after interface
 443          * or after endpoint descriptors
 444          */
 445         if (hid_parse_hid_descr(&hidp->hid_hid_descr, USB_HID_DESCR_SIZE,
 446             altif_data, ep_data) != USB_HID_DESCR_SIZE) {
 447                 /*
 448                  * If parsing of hid descriptor failed and
 449                  * the device is a keyboard or mouse, use predefined
 450                  * length and packet size.
 451                  */
 452                 if (hid_parse_hid_descr_failure(hidp) == USB_FAILURE) {
 453                         mutex_exit(&hidp->hid_mutex);
 454 
 455                         goto fail;
 456                 }




 417          * Make sure that the bInterfaceProtocol only has meaning to
 418          * Boot Interface Subclass.
 419          */
 420         if (hidp->hid_if_descr.bInterfaceSubClass != BOOT_INTERFACE)
 421                 hidp->hid_if_descr.bInterfaceProtocol = NONE_PROTOCOL;
 422         mutex_exit(&hidp->hid_mutex);
 423 
 424         if ((ep_data = usb_lookup_ep_data(dip, dev_data,
 425             hidp->hid_interfaceno, 0, 0,
 426             (uint_t)USB_EP_ATTR_INTR, (uint_t)USB_EP_DIR_IN)) == NULL) {
 427 
 428                 USB_DPRINTF_L2(PRINT_MASK_ATTA, hidp->hid_log_handle,
 429                     "no interrupt IN endpoint found");
 430 
 431                 goto fail;
 432         }
 433 
 434         mutex_enter(&hidp->hid_mutex);
 435         if (usb_ep_xdescr_fill(USB_EP_XDESCR_CURRENT_VERSION, dip, ep_data,
 436             &hidp->hid_ep_intr_xdescr) != USB_SUCCESS) {
 437                 mutex_exit(&hidp->hid_mutex);
 438 
 439                 goto fail;
 440         }
 441 
 442         /*
 443          * Attempt to find the hid descriptor, it could be after interface
 444          * or after endpoint descriptors
 445          */
 446         if (hid_parse_hid_descr(&hidp->hid_hid_descr, USB_HID_DESCR_SIZE,
 447             altif_data, ep_data) != USB_HID_DESCR_SIZE) {
 448                 /*
 449                  * If parsing of hid descriptor failed and
 450                  * the device is a keyboard or mouse, use predefined
 451                  * length and packet size.
 452                  */
 453                 if (hid_parse_hid_descr_failure(hidp) == USB_FAILURE) {
 454                         mutex_exit(&hidp->hid_mutex);
 455 
 456                         goto fail;
 457                 }