-
Notifications
You must be signed in to change notification settings - Fork 151
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
Fix HID device open failure handling #30
base: master
Are you sure you want to change the base?
Fix HID device open failure handling #30
Conversation
When the ACM device could be opened to restart into the bootloader, but the HID device was detected but failed to open (for example because of a permission problem), this would not be detected and the code would segfault because `handle` was NULL. The code that was supposed to handle a NULL return value from `hid_open` actually triggered only on a *non-null* value, and apparently also only when the "looking for hid device" loop above had reached i = 10 (in which case some error handling above would have bailed out already). This changes the code to just check for a NULL return value, and bail out in that case.
In the Arduino IDE (with the Arduino_Core_STM32 core), this looked like this:
I noticed the segfault in dmesg:
|
Hi. Any idea what permission may be missing? My device shows up properly in /dev/ttyACM0, but at hid_open there is a null handle. |
Does the F4 version build for you ? I'm getting errors about missing headers :-( BTW. |
@rogerclarkmelbourne, I haven't tried compiling the bootloader itself, sorry. I just used the prebuilt version and noticed a bug in the hid-flash utility.
That's overstating things, I was just testing a little bit to see if the core changes I made did not break the HID bootloader upload, I'm really not working on the bootloader itself (and have little interest in doing so, we use the builtin hardware bootloader). |
No worries. I contacted @Serasidis and he has pushed and update to fix the problem. |
I don't understand, why hasn't this been merged yet? |
When the ACM device could be opened to restart into the bootloader, but
the HID device was detected but failed to open (for example because of a
permission problem), this would not be detected and the code would
segfault because
handle
was NULL.The code that was supposed to handle a NULL return value from
hid_open
actually triggered only on a non-null value, and apparently also only
when the "looking for hid device" loop above had reached i = 10 (in
which case some error handling above would have bailed out already).
This changes the code to just check for a NULL return value, and bail
out in that case.