This is an automated email from the ASF dual-hosted git repository.
sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new d919ff517 sensors/dps368: Fix memory access in soft reset
d919ff517 is described below
commit d919ff517d1c2a669d0d22ee1aea6dadd2d04860
Author: Wiktor Kwiatkowski <[email protected]>
AuthorDate: Tue Aug 18 14:59:53 2026 +0200
sensors/dps368: Fix memory access in soft reset
Use CONTAINER_OF to get the dps368 pointer from the sensor pointer.
Direct casting caused wrong memory access when handling errors.
---
hw/drivers/sensors/dps368/src/dps368.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/drivers/sensors/dps368/src/dps368.c
b/hw/drivers/sensors/dps368/src/dps368.c
index e65bc1783..57a6b0ca2 100644
--- a/hw/drivers/sensors/dps368/src/dps368.c
+++ b/hw/drivers/sensors/dps368/src/dps368.c
@@ -706,14 +706,16 @@ int dps368_soft_reset(struct sensor *sensor)
uint8_t ready;
struct sensor_itf *itf;
+ struct dps368 *dps368;
+ dps368 = CONTAINER_OF(sensor, struct dps368, sensor);
itf = SENSOR_GET_ITF(sensor);
rc = dps368_write_reg(itf, IFX_DPS368_SOFT_RESET_REG_ADDR,
IFX_DPS368_SOFT_RESET_REG_DATA);
if (rc) {
- STATS_INC(((struct dps368 *)sensor)->stats, write_errors);
+ STATS_INC(dps368->stats, write_errors);
return rc;
}
@@ -722,7 +724,7 @@ int dps368_soft_reset(struct sensor *sensor)
/*Check if sensor is back */
if ((rc = dps368_is_init_complete(itf, &ready))) {
- STATS_INC(((struct dps368 *)sensor)->stats, read_errors);
+ STATS_INC(dps368->stats, read_errors);
return rc;
}
@@ -734,7 +736,7 @@ int dps368_soft_reset(struct sensor *sensor)
/*perform post init sequence*/
if ((rc = dps368_set_oem_parameters(itf))) {
- STATS_INC(((struct dps368 *)sensor)->stats, write_errors);
+ STATS_INC(dps368->stats, write_errors);
return rc;
}