pm: add debug_assert for cb register/unregister api

avoid the register/unregister API access wrong memory

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
buxiasen 2024-06-11 22:07:03 +08:00 committed by Xiang Xiao
parent e11a53bec9
commit 9d396bf89e
2 changed files with 10 additions and 2 deletions

View File

@ -57,8 +57,12 @@
int pm_domain_register(int domain, FAR struct pm_callback_s *cb)
{
FAR struct pm_domain_s *pdom;
irqstate_t flags;
struct pm_domain_s *pdom = &g_pmdomains[domain];
DEBUGASSERT(domain >= 0 && domain < CONFIG_PM_NDOMAINS);
pdom = &g_pmdomains[domain];
flags = spin_lock_irqsave(&pdom->lock);
/* Add the new entry to the end of the list of registered callbacks */

View File

@ -56,8 +56,12 @@
int pm_domain_unregister(int domain, FAR struct pm_callback_s *cb)
{
FAR struct pm_domain_s *pdom;
irqstate_t flags;
struct pm_domain_s *pdom = &g_pmdomains[domain];
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. */