fix(gps): guard against NULL serial port when GPS provider changed without reboot#11634
Open
daijoubu wants to merge 1 commit into
Open
fix(gps): guard against NULL serial port when GPS provider changed without reboot#11634daijoubu wants to merge 1 commit into
daijoubu wants to merge 1 commit into
Conversation
…thout reboot Driver-based providers (MSP, FAKE) leave gpsState.gpsPort NULL because gpsInit() skips serial port opening for them. If gps_provider is then changed via CLI to a serial-based provider without rebooting, the next gpsUpdate() tick dispatches into the serial protocol handler with a NULL port, causing a hard fault. Add a guard in gpsUpdate() that returns false early when a serial-based provider is configured but no port is open. Also guard gpsEnablePassthrough() which had the same latent NULL dereference.
Contributor
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Test firmware build ready — commit Download firmware for PR #11634 238 targets built. Find your board's
|
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.
Summary
Fixes a hard fault that occurs when
gps_provideris changed via CLI to a serial-based provider (e.g.UBLOX) after booting with a driver-based provider (MSPorFAKE) without rebooting.Driver-based providers skip serial port opening in
gpsInit(), leavinggpsState.gpsPort = NULL. On the next scheduler tick,gpsUpdate()dispatches into the serial protocol handler which callsserialRxBytesWaiting(NULL)→ hard fault.Changes
src/main/io/gps.c: Added guard ingpsUpdate()— returns false early when a serial-based provider is configured butgpsPortis NULL. Also added a NULL check ingpsEnablePassthrough()which had the same latent dereference.src/test/unit/gps_null_port_unittest.cc: Unit test reproducing the bug (4 cases: RUNNING state crash, INITIALIZING state, positive non-NULL path, feature-disabled path).Testing
NullPortInRunningState_ShouldNotCrashfails before the fix (serialRxBytesWaiting called with NULL), passes after.set gps_provider = MSPon boot, thenset gps_provider = UBLOXvia CLI without reboot — board remained responsive, no hard fault.