libs/modlib: close fd when error happen
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
3017cc4402
commit
13bdaaec99
3 changed files with 3 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue