Repository navigation
Conversation
|
Note that this pull request conversation and title doesn't get included in the git log, so please add an explanation to the commit message as well. |
… clean up hotplug related lists that arent initialized. Moving hotplug_init before makes sure the lists are valid so if backend.init fails they get cleaned up without errors.
d879fbf to
9855471
Compare
done. squashed with capturing the title as a commit message |
|
Anything else needed before this can be merged ? |
|
It would be good if one of core developers who actually touched this code would chime in and say, yes, this was an oversight, or, no, this should be dealt with differently. But from the look of it, the suggested patch and explanation, thumbs up from me. You still have an unfinished commit message though, I would suggest having "Fix segmentation fault in libusb_init() if backend.init fails" on the first line, a second empty line, then the already existing explanation. |
|
Chris seems to be busy and not able to review as of now. |
|
@ankurverma85 are you sure that the init order is wrong here? Maybe the exit/cleanup order is wrong instead. Because your move of the usbi_hotplug_init call before the usbi_backend.init call might not be allowed. Maybe usbi_hotplug_init assumes/requires an initialized backend. |
|
The suggested change is at least consistent with how it was before the above-mentioned commit. What's inside usbi_hotplug_init() used to be called before usbi_backend.init(), see 32a2206#diff-c1f9bc250077d41456a3e580fca0ddf5d8c25b741bff6d9b9505990a8b70b254L2296 |
|
@tormodvolden You're correct. I take my question back and agree with the suggested change. |
The initial enumeration should not result in hotplug events to be fired. This is just a convenience though, API users still need to be prepared to be notified a second time fora device that was plugged in between libusb_init and libusb_hotplug_register_callback. This regressed with commit 6929b82 ("Fix segmentation fault in libusb_init() if usbi_backend.init() fails"). This commit avoids the mentioned segmentation fault by avoiding to clean up the hotplug code if it was not yet initialised. Closes: libusb#1082 Related: libusb#989
This tests that the initial device enumeration correctly triggers events for the existing devices with LIBUSB_HOTPLUG_ENUMERATE, but does not trigger any events beyond that. Unfortunately, a regression test for the crash happening in issue libusb#989 is not easily possible, as there is no way to inject an error into the linux_usbfs op_init function using umockdev.
The initial enumeration should not result in hotplug events to be fired. This is just a convenience though, API users still need to be prepared to be notified a second time fora device that was plugged in between libusb_init and libusb_hotplug_register_callback. This regressed with commit 6929b82 ("Fix segmentation fault in libusb_init() if usbi_backend.init() fails"). This commit avoids the mentioned segmentation fault by avoiding to clean up the hotplug code if it was not yet initialised. Closes: libusb#1082 Related: libusb#989
This tests that the initial device enumeration correctly triggers events for the existing devices with LIBUSB_HOTPLUG_ENUMERATE, but does not trigger any events beyond that. Unfortunately, a regression test for the crash happening in issue libusb#989 is not easily possible, as there is no way to inject an error into the linux_usbfs op_init function using umockdev.
The initial enumeration should not result in hotplug events to be fired. This is just a convenience though, API users still need to be prepared to be notified a second time fora device that was plugged in between libusb_init and libusb_hotplug_register_callback. This regressed with commit 6929b82 ("Fix segmentation fault in libusb_init() if usbi_backend.init() fails"). This commit avoids the mentioned segmentation fault by avoiding to clean up the hotplug code if it was not yet initialised. Closes libusb#1082 References libusb#989
The initial enumeration should not result in hotplug events to be fired. This is just a convenience though, API users still need to be prepared to be notified a second time fora device that was plugged in between libusb_init and libusb_hotplug_register_callback. This regressed with commit 6929b82 ("Fix segmentation fault in libusb_init() if usbi_backend.init() fails"). This commit avoids the mentioned segmentation fault by avoiding to clean up the hotplug code if it was not yet initialised. Closes: libusb#1082 Related: libusb#989
The initial enumeration should not result in hotplug events to be fired. This is just a convenience though, API users still need to be prepared to be notified a second time for a device that was plugged in between libusb_init and libusb_hotplug_register_callback. This regressed with commit 6929b82 ("Fix segmentation fault in libusb_init() if usbi_backend.init() fails"). This commit avoids the mentioned segmentation fault by avoiding to clean up the hotplug code if it was not yet initialised. Fixes #1082 Closes #1090 References #989
If backend.init fails. the control goes to err_io_exit which tries to clean up hotplug related lists that arent initialized.
Moving hotplug_init before makes sure the lists are valid so if backend.init fails they get cleaned up without errors.
Also adding mutx_unlock to a few more error scenarios