drivers: Destroy mutex and sem in the error path

also correct the order to ensure the memory free is last step

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2022-10-17 00:50:59 +08:00
committed by Masayuki Ishikawa
parent dee38ce3e8
commit dca5a3483f
45 changed files with 110 additions and 46 deletions
+4
View File
@@ -806,6 +806,10 @@ int ramlog_register(FAR const char *devpath, FAR char *buffer, size_t buflen)
ret = register_driver(devpath, &g_ramlogfops, 0666, priv);
if (ret < 0)
{
nxmutex_destroy(&priv->rl_lock);
#ifndef CONFIG_RAMLOG_NONBLOCKING
nxsem_destroy(&priv->rl_waitsem);
#endif
kmm_free(priv);
}
}