libusb: fix crash in hid_enumerate() caused by a stale device handle#526
libusb: fix crash in hid_enumerate() caused by a stale device handle#526Youw merged 1 commit intolibusb:masterfrom
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 |
Youw
left a comment
There was a problem hiding this comment.
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().