xhh233 commented on issue #22171:
URL: https://github.com/apache/nuttx/issues/22171#issuecomment-7093439706

   Candidate patch (against the pinned snapshot; `git apply --check` clean):
   
   ```diff
   --- a/drivers/power/pm/pm_unregister.c
   +++ b/drivers/power/pm/pm_unregister.c
   @@ -27,6 +27,7 @@
    #include <nuttx/config.h>
    
    #include <assert.h>
   +#include <errno.h>
    
    #include <nuttx/queue.h>
    #include <nuttx/power/pm.h>
   @@ -60,17 +61,30 @@
    {
      FAR struct pm_domain_s *pdom;
      irqstate_t flags;
   +  int ret = OK;
    
      DEBUGASSERT(domain >= 0 && domain < CONFIG_PM_NDOMAINS);
    
      pdom  = &g_pmdomains[domain];
      flags = spin_lock_irqsave(&pdom->lock);
    
   -  /* Remove entry from the list of registered callbacks. */
   +  /* Remove entry from the list of registered callbacks.  Only remove an
   +   * entry that is still queued: dq_rem() on an already-removed entry has
   +   * NULL links and would clear the queue head and tail, silently dropping
   +   * every other registered driver.
   +   */
   +
   +  if (dq_inqueue(&cb->entry, &pdom->registry))
   +    {
   +      dq_rem(&cb->entry, &pdom->registry);
   +    }
   +  else
   +    {
   +      ret = -ENOENT;
   +    }
    
   -  dq_rem(&cb->entry, &pdom->registry);
      spin_unlock_irqrestore(&pdom->lock, flags);
   -  return OK;
   +  return ret;
    }
    
    #endif /* CONFIG_PM */
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to