Fix crash when SteelSeries Nimbus controller connects (#4816) [$25 Bounty]#18831
Closed
ma-moon wants to merge 1 commit intolibretro:masterfrom
Closed
Fix crash when SteelSeries Nimbus controller connects (#4816) [$25 Bounty]#18831ma-moon wants to merge 1 commit intolibretro:masterfrom
ma-moon wants to merge 1 commit intolibretro:masterfrom
Conversation
…ereference) - Add NULL checks for hid pointer in iohidmanager_hid_device_add(), iohidmanager_hid_device_remove(), and iohidmanager_hid_device_input_callback() - Prevents segmentation fault when HID driver data is not initialized - Fixes issue libretro#4816
Collaborator
|
This was fixed a long time ago already and just wasn't closed. Were you able to confirm that this still exists? |
Author
|
CI passes. Ready for review. |
Collaborator
|
You didn't even read my comment nor the full set of comments on the original issue. This was fixed a long, long time ago. |
Collaborator
|
Incidentally I did get out my Nimbus and tried with HID and confirmed it is working without this fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a segmentation fault that occurs when connecting a SteelSeries Nimbus controller (and potentially other HID controllers) on macOS.
Root Cause
The crash was caused by NULL pointer dereferences in three functions:
iohidmanager_hid_device_add()- accessedhid->slotsbefore checking ifhidwas NULLiohidmanager_hid_device_remove()- accessedhid->slotsbefore checking ifhidwas NULLiohidmanager_hid_device_input_callback()- accessedhid->hats/axes/buttonswithout NULL checkThe
hid_driver_get_data()function can return NULL when the HID driver is not properly initialized, which can happen during controller hot-plug events.Fix
Added early NULL checks at the beginning of each affected function to prevent dereferencing NULL pointers.
Changes
iohidmanager_hid_device_add(): Check hid before accessing hid->slotsTesting
Bounty
This fix addresses issue #4816 with a $25 bounty.