rptun: init the semtx before the thread/workqueue created

If the rptun driver set auto start, the smetx may has been used
in rptun_notify_wait() but not inited.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
This commit is contained in:
wangbowen6 2023-04-25 11:22:32 +08:00 committed by Xiang Xiao
parent 372fba70bb
commit 41e399aa43

View File

@ -1194,6 +1194,8 @@ int rptun_initialize(FAR struct rptun_dev_s *dev)
goto err_driver;
}
nxsem_init(&priv->semtx, 0, 0);
#ifdef CONFIG_RPTUN_WORKQUEUE
if (RPTUN_IS_AUTOSTART(dev))
{
@ -1221,13 +1223,12 @@ int rptun_initialize(FAR struct rptun_dev_s *dev)
if (ret < 0)
{
unregister_driver(name);
nxsem_destroy(&priv->semtx);
nxsem_destroy(&priv->semrx);
goto err_driver;
}
#endif
nxsem_init(&priv->semtx, 0, 0);
/* Add priv to list */
nxrmutex_lock(&g_rptun_lockcb);