mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
libs/modlib: close fd when error happen
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -196,7 +196,7 @@ static inline FAR void *dlinsert(FAR const char *filename)
|
||||
if (ret != 0)
|
||||
{
|
||||
serr("ERROR: Failed to initialize to load module: %d\n", ret);
|
||||
goto errout_with_lock;
|
||||
goto errout_with_loadinfo;
|
||||
}
|
||||
|
||||
/* Allocate a module registry entry to hold the module data */
|
||||
@@ -296,7 +296,6 @@ errout_with_registry_entry:
|
||||
lib_free(modp);
|
||||
errout_with_loadinfo:
|
||||
modlib_uninitialize(&loadinfo);
|
||||
errout_with_lock:
|
||||
modlib_registry_unlock();
|
||||
set_errno(-ret);
|
||||
return NULL;
|
||||
|
||||
@@ -173,8 +173,7 @@ int modlib_initialize(FAR const char *filename,
|
||||
*/
|
||||
|
||||
berr("ERROR: Bad ELF header: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ int modlib_uninitialize(FAR struct mod_loadinfo_s *loadinfo)
|
||||
if (loadinfo->filfd >= 0)
|
||||
{
|
||||
_NX_CLOSE(loadinfo->filfd);
|
||||
loadinfo->filfd = -1;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
Reference in New Issue
Block a user