This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ae4ef43db1ba656aea3a8a7dcb35419667025074 Author: raiden00pl <[email protected]> AuthorDate: Thu Oct 22 12:55:57 2026 +0200 wireless/ieee802154: keep no received frames on a closed MAC device The MAC character device queued received data frames while no instance was open and kept them after the last close, each holding an IOB. Assisted-by: Claude Code Signed-off-by: raiden00pl <[email protected]> --- wireless/ieee802154/mac802154_device.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 453472b4164..186a0946928 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -293,6 +293,24 @@ static int mac802154dev_close(FAR struct file *filep) kmm_free(opriv); + /* Nobody can read the received frames once the last instance is closed */ + + if (dev->md_open == NULL) + { + FAR struct ieee802154_data_ind_s *ind; + + ind = (FAR struct ieee802154_data_ind_s *) + sq_remfirst(&dev->dataind_queue); + + while (ind) + { + ieee802154_primitive_free( + (FAR struct ieee802154_primitive_s *)ind); + ind = (FAR struct ieee802154_data_ind_s *) + sq_remfirst(&dev->dataind_queue); + } + } + /* If there are now no open instances of the driver, purge the list of * events. A registered notification is of no use without an instance to * read the events, drop it. @@ -766,6 +784,14 @@ static int mac802154dev_rxframe(FAR struct mac802154_chardevice_s *dev, while (nxmutex_lock(&dev->md_lock) != 0); + /* Nobody can read the frame if the device is not open */ + + if (dev->md_open == NULL) + { + nxmutex_unlock(&dev->md_lock); + return -ENODEV; + } + /* Push the indication onto the list */ sq_addlast((FAR sq_entry_t *)ind, &dev->dataind_queue);
