acassis commented on code in PR #18104:
URL: https://github.com/apache/nuttx/pull/18104#discussion_r2716525823
##########
include/nuttx/notifier.h:
##########
@@ -212,10 +212,12 @@ extern "C"
do \
{ \
FAR struct atomic_notifier_head *nh = (nhead); \
- irqstate_t flags; \
- flags = rspin_lock_irqsave_nopreempt(&nh->lock); \
- notifier_call_chain(nh->head, (val), (v), -1, NULL); \
- rspin_unlock_irqrestore_nopreempt(&nh->lock, flags); \
+ if (nh->head) \
Review Comment:
It is important to be defensive here, because atomic_notifier_call_chain()
can be called with a NULL nhead, i.e.: see watchdog_automonitor_timeout()
##########
include/nuttx/notifier.h:
##########
@@ -262,12 +264,15 @@ extern "C"
do \
{ \
FAR struct blocking_notifier_head *nh = (nhead); \
- if (nxmutex_lock(&nh->mutex) < 0) \
+ if (nh->head) \
Review Comment:
```suggestion
if (nh != NULL && nh->head != NULL) \
##########
include/nuttx/notifier.h:
##########
@@ -212,10 +212,12 @@ extern "C"
do \
{ \
FAR struct atomic_notifier_head *nh = (nhead); \
- irqstate_t flags; \
- flags = rspin_lock_irqsave_nopreempt(&nh->lock); \
- notifier_call_chain(nh->head, (val), (v), -1, NULL); \
- rspin_unlock_irqrestore_nopreempt(&nh->lock, flags); \
+ if (nh->head) \
Review Comment:
```suggestion
if (nh != NULL && nh->head != NULL) \
--
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]