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 -5
View File
@@ -863,11 +863,7 @@ int mac802154dev_register(MACHANDLE mac, int minor)
if (ret < 0)
{
nerr("ERROR: Failed to bind the MAC callbacks: %d\n", ret);
/* Free memory and return the error */
kmm_free(dev);
return ret;
goto errout_with_priv;
}
/* Create the character device name */
+1
View File
@@ -1338,6 +1338,7 @@ int mac802154netdev_register(MACHANDLE mac)
return macnet_ifdown(&priv->md_dev.r_dev);
errout:
nxmutex_destroy(&priv->md_lock);
/* Free memory and return the error */