This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch releases/12.11
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 3af0ab64bbdcd9b45450363c4e2dfeb8804fa9f9
Author: Huang Qi <[email protected]>
AuthorDate: Sat Sep 20 12:05:32 2025 +0800

    arch/risc-v: espressif: temperature: Fix incorrect pointer casting
    
    Fix bug in temperature sensor driver where direct casting of lower half
    structure pointer could lead to incorrect memory access.
    
    Signed-off-by: Huang Qi <[email protected]>
---
 arch/risc-v/src/common/espressif/esp_temperature_sensor.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/risc-v/src/common/espressif/esp_temperature_sensor.c 
b/arch/risc-v/src/common/espressif/esp_temperature_sensor.c
index b4ad23588ca..4ba7478d46d 100644
--- a/arch/risc-v/src/common/espressif/esp_temperature_sensor.c
+++ b/arch/risc-v/src/common/espressif/esp_temperature_sensor.c
@@ -714,7 +714,8 @@ static int esp_temperature_sensor_set_interval(
   struct file *filep,
   uint32_t *period_us)
 {
-  struct esp_temp_priv_s *priv = (struct esp_temp_priv_s *)lower;
+  struct esp_temp_priv_s *priv =
+    container_of(lower, struct esp_temp_priv_s, lower);
 
   if (*period_us < ESP_TEMP_MIN_INTERVAL)
     {
@@ -753,7 +754,8 @@ static int esp_temperature_sensor_activate(
   struct file *filep,
   bool enable)
 {
-  struct esp_temp_priv_s *priv = (struct esp_temp_priv_s *)lower;
+  struct esp_temp_priv_s *priv =
+    container_of(lower, struct esp_temp_priv_s, lower);
 #ifdef CONFIG_ESPRESSIF_TEMP_UORB_POLL
   bool start_thread = false;
 #endif

Reply via email to