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
+1
View File
@@ -1112,6 +1112,7 @@ int cypress_mbr3108_register(FAR const char *devpath,
ret = register_driver(devpath, &g_mbr3108_fileops, 0666, priv);
if (ret < 0)
{
nxmutex_destroy(&priv->devlock);
kmm_free(priv);
mbr3108_dbg("Error occurred during the driver registering\n");
return ret;
+1
View File
@@ -302,6 +302,7 @@ STMPE811_HANDLE stmpe811_instantiate(FAR struct i2c_master_s *dev,
ret = stmpe811_checkid(priv);
if (ret < 0)
{
nxmutex_destroy(&priv->lock);
#ifdef CONFIG_STMPE811_MULTIPLE
g_stmpe811list = priv->flink;
kmm_free(priv);