mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +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
@@ -1580,6 +1580,7 @@ errout_with_interrupts:
|
||||
|
||||
errout_with_lock:
|
||||
nxmutex_destroy(&priv->lock);
|
||||
kmm_free(priv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1134,6 +1134,7 @@ int ht16k33_register(int devno, FAR struct i2c_master_s *i2c)
|
||||
if (ret < 0)
|
||||
{
|
||||
snerr("ERROR: Failed to register driver: %d\n", ret);
|
||||
nxmutex_destroy(&priv->lock);
|
||||
kmm_free(priv);
|
||||
}
|
||||
|
||||
|
||||
@@ -1664,6 +1664,7 @@ int pcf8574_lcd_backpack_register(FAR const char *devpath,
|
||||
if (ret < 0)
|
||||
{
|
||||
lcdinfo("Failed to register driver: %d\n", ret);
|
||||
nxmutex_destroy(&priv->lock);
|
||||
kmm_free(priv);
|
||||
}
|
||||
|
||||
|
||||
@@ -1060,6 +1060,7 @@ int st7032_register(FAR const char *devpath, FAR struct i2c_master_s *i2c)
|
||||
if (ret < 0)
|
||||
{
|
||||
snerr("ERROR: Failed to register driver: %d\n", ret);
|
||||
nxmutex_destroy(&priv->lock);
|
||||
kmm_free(priv);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user