Hi Guys,
I'm working on a linux gamepad implementation using libusb and it's working
great so far. Thank you for the wonderful project :)
One thing I did notice is when my gamepad gets unplugged there are
sometimes segfault generated.
At arrive callback, I call libusb_open and saved two things:
libusb_device *dev;
libusb_device_handle *dev_handle;
At left callback, I do this:
libusb_close(dev_handle);
dev = NULL;
Is setting NULL pointer a bad idea and should I just let libusb handle all
the cases? I sometimes send rumble command to the gamepad, which doesn't
actually comes from the same thread that handle_event gets called. I use
the NULL pointer
After some investigation, I have found two cases where the segfault can
happen.
1. In linux_usbfs.c in function op_handle_events():
If list_for_each_entry on ctx->open_devs never get into the loop, the
hpriv will
be NULL and usbi_remove_pollfd will trigger a segfault. A simple null check
on the hpriv will get us off this one but I'm not sure if this is desired.
2. In linux_usbfs.c in function submit_bulk_transfer
usbi_err(TRANSFER_CTX(transfer), "submiturb failed error %d errno=%d", r,
errno);
TRANSFER_CTX(transfer) refers to transfer->dev_hanlde->dev->ctx, which dev
can be either NULL if I set it or some invalid value like 0x10.
Thanks,
Kuangye
--
Kuangye (Vincent) Guo
kuangye....@gmail.com
(347)-463-4248
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel