linux_usbfs: op_handle_events: Protect against not finding the device-handle
authorHans de Goede <hdegoede@redhat.com>
Fri, 30 May 2014 09:38:07 +0000 (11:38 +0200)
committerHans de Goede <hdegoede@redhat.com>
Fri, 30 May 2014 09:38:07 +0000 (11:38 +0200)
commitd7e763e277db4ecafa66f20684ab751e680b0557
tree9c8f6bfef4619a199089be2d200189125f2e6713
parent8af0e460e1640f63b04d2a5db949dc88d890dff0
linux_usbfs: op_handle_events: Protect against not finding the device-handle

We scan the list of open devices to find the device-handle based on the fd,
add a check to ensure that we've actually found the handle before continuing.

This fixes the following Coverity warning:

*** CID 62575:  Explicit null dereferenced  (FORWARD_NULL)
/libusb/os/linux_usbfs.c: 2594 in op_handle_events()
2588      hpriv = _device_handle_priv(handle);
2589      if (hpriv->fd == pollfd->fd)
2590      break;
2591      }
2592
2593      if (pollfd->revents & POLLERR) {
>>>     CID 62575:  Explicit null dereferenced  (FORWARD_NULL)
>>>     Dereferencing null pointer "hpriv".
2594      usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->fd);
2595      usbi_handle_disconnect(handle);
2596      /* device will still be marked as attached if hotplug
monitor thread
2597       * hasn't processed remove event yet */
2598      usbi_mutex_static_lock(&linux_hotplug_lock);
2599      if (handle->dev->attached)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/os/linux_usbfs.c
libusb/version_nano.h