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

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit e9774174625839a8bce3b9024fc58408f84b6944
Author: dongjiuzhu1 <[email protected]>
AuthorDate: Sat Jul 26 11:28:56 2025 +0800

    drivers/sensors/sensor_rpmsg: Skip config sync for an unread state.
    
    sensor_rpmsg_alloc_proxy() returns an existing proxy before it reads
    the local state. The ADVERTISE and SUBSCRIBE_ACK handlers then pass an
    uninitialized struct sensor_state_s to sensor_rpmsg_update_config(),
    which forwards random interval, batch latency and wakeup values to the
    remote core.
    
    Mark the state as invalid with esize = UINT32_MAX before calling
    sensor_rpmsg_alloc_proxy(), and return from
    sensor_rpmsg_update_config() when the state was not filled.
    
    Signed-off-by: dongjiuzhu1 <[email protected]>
---
 drivers/sensors/sensor_rpmsg.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/sensors/sensor_rpmsg.c b/drivers/sensors/sensor_rpmsg.c
index 3f275230843..dd640bb9c44 100644
--- a/drivers/sensors/sensor_rpmsg.c
+++ b/drivers/sensors/sensor_rpmsg.c
@@ -1189,6 +1189,13 @@ sensor_rpmsg_find_dev(FAR const char *path)
 static void sensor_rpmsg_update_config(FAR struct sensor_rpmsg_dev_s *dev,
                                        FAR struct sensor_state_s *state)
 {
+  if (state->esize == UINT32_MAX)
+    {
+      /* Invalid esize of state */
+
+      return;
+    }
+
   /* sync interval and latency */
 
   if (state->min_interval != UINT32_MAX)
@@ -1224,6 +1231,7 @@ static int sensor_rpmsg_adv_handler(FAR struct 
rpmsg_endpoint *ept,
       return 0;
     }
 
+  state.esize = UINT32_MAX;
   proxy = sensor_rpmsg_alloc_proxy(dev, ept, msg, &state);
   if (!proxy)
     {
@@ -1331,6 +1339,7 @@ static int sensor_rpmsg_suback_handler(FAR struct 
rpmsg_endpoint *ept,
   FAR struct sensor_rpmsg_dev_s *dev;
   struct sensor_state_s state;
 
+  state.esize = UINT32_MAX;
   dev = sensor_rpmsg_find_dev(msg->path);
   if (dev && (!dev->nsubscribers ||
       !sensor_rpmsg_alloc_proxy(dev, ept, msg, &state)))

Reply via email to