Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensor: ism330dhcx: Incorrect handle passed to ctx struct in SPI mode #60119

Conversation

tristan-google
Copy link
Collaborator

The ISM330DHCX driver immediately segfaults when run in SPI mode. A bad pointer is being passed into the dev param of ism330dhcx_spi_read. Tracing this back, it appears that the handle field of the ctx struct is being set to the device's data struct while ism330dhcx_spi_read expects ctx->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 the const qualifier, but this is how it is done in I2C mode (see ism330dhcx_i2c_init()). The only other way would be to change the declaration of stmdev_ctx_t, which is owned by the HAL module.

The ISM330DHCX driver immediately segfaults when run in SPI mode. A bad
pointer is being passed into the `dev` param of `ism330dhcx_spi_read`.
Tracing this back, it appears that the handle field of the ctx struct
is being set to the device's data struct while `ism330dhcx_spi_read`
expects `ctx->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 the
`const` qualifier, but this is how it is done in I2C mode (see
`ism330dhcx_i2c_init()`). The only other way would be to change the
declaration of `stmdev_ctx_t`, which is owned by the HAL module.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
@fabiobaltieri fabiobaltieri added the Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc. label Jul 6, 2023
@fabiobaltieri fabiobaltieri merged commit 3b59d68 into zephyrproject-rtos:main Jul 7, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors Hotfix Fix for issues blocking development, i.e. CI issues, tests failing in CI, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants