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

Commits on Jul 6, 2023

  1. sensor: ism330dhcx: Incorrect handle passed to ctx struct in SPI mode

    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>
    tristan-google committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    4ee116c View commit details
    Browse the repository at this point in the history