Fix NULL pointer dereference in STM32 SPI construct#10924
Closed
ChrisNourse wants to merge 1 commit intoadafruit:mainfrom
Closed
Fix NULL pointer dereference in STM32 SPI construct#10924ChrisNourse wants to merge 1 commit intoadafruit:mainfrom
ChrisNourse wants to merge 1 commit intoadafruit:mainfrom
Conversation
Move mark_deinit() before check_pins() so that self->sck is not NULLed after check_pins sets it. The previous ordering caused a NULL dereference of self->sck->altfn_index, crashing all STM32 boards that use SPI (including STM32F405 boards whose CIRCUITPY filesystem lives on external SPI flash). Fixes adafruit#10866 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dhalbert
approved these changes
Apr 7, 2026
Collaborator
dhalbert
left a comment
There was a problem hiding this comment.
Thanks for finding this!!
I would have asked you to submit this against 10.1.x instead of main, but we are planning to release 10.2.0 within a week or two. If you would like to see this in a numbered release really really soon, you can resubmit against 10.1.x and I'll make a release within a couple of days.
Author
|
Amazing! I Created a new PR Closing this one |
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
common_hal_busio_spi_construct()on the STM32 port that crashed all STM32 boards using SPI (including STM32F405 boards whose CIRCUITPY filesystem lives on external SPI flash).common_hal_busio_spi_mark_deinit(self)call (added in 6b458a9) was placed aftercheck_pins(), which setsself->sck.mark_deinitthen NULLedself->sck, and the immediately followingself->sck->altfn_indexdereference caused a crash.mark_deinit()beforecheck_pins(), aligning the STM port with every other port (espressif, nordic, raspberrypi, atmel-samd, mimxrt10xx, etc.) which all callmark_deinitfirst.Fixes #10866
Test plan
feather_stm32f405_express— compiles cleanlystorage.getmount('/'),os.listdir('/'),os.statvfs('/')busio.SPI(board.SCK, board.MOSI, board.MISO)construct/deinit works🤖 Generated with Claude Code