mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
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:
committed by
Masayuki Ishikawa
parent
dee38ce3e8
commit
dca5a3483f
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user