-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libusb: fix crash in hid_enumerate() caused by a stale device handle #526
Conversation
When hid_enumerate() iterates over the device list, it's possible that libusb_open() fails. If this occurs on the next round after a successful libusb_open() call, create_device_info_for_device() is passed the previous iteration's already closed device handle. Fix the crash by setting the handle to NULL after libusb_close(). Signed-off-by: Juuso Alasuutari <juuso.alasuutari@gmail.com>
a3678be
to
e21bad5
Compare
FYI: I reworded the commit message slightly, hence the force-push. |
This may or may not be useful, but here's a backtrace from gdb. To be honest I didn't find this nearly as helpful as sprinkling a few printfs in The logic is pretty obvious when reading through
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now when I look at the fix, my though - how come no one had hit this one until now?
Thanks!
Human brains are to blame, they're always causing stuff like this. :) I think it went unnoticed because it seems to only show up when
|
When hid_enumerate() iterates over the device list, it's possible that libusb_open() fails. If this occurs on the next round after a successful libusb_open() call, create_device_info_for_device() is passed the previous iteration's already closed device handle.
Fix the crash by setting the handle to NULL after libusb_close().