sensor: ism330dhcx: Incorrect handle passed to ctx struct in SPI mode #60119
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.
The ISM330DHCX driver immediately segfaults when run in SPI mode. A bad pointer is being passed into the
dev
param ofism330dhcx_spi_read
. Tracing this back, it appears that the handle field of the ctx struct is being set to the device's data struct whileism330dhcx_spi_read
expectsctx->handle
to be a pointer to a device struct.Modify
ism330dhcx_spi_init()
to insert the correct pointer into the context struct. Unfortunately this requires a cast to discard theconst
qualifier, but this is how it is done in I2C mode (seeism330dhcx_i2c_init()
). The only other way would be to change the declaration ofstmdev_ctx_t
, which is owned by the HAL module.