Skip to content

Commit

Permalink
libs/libc/modlib/modlib_bind.c: Fix system crash if modlib_bind fails
Browse files Browse the repository at this point in the history
Addrenv is changed to the newly created process' one in the beginning of
modlib_bind, and needs to be changed always when returning from the function;
also in error cases.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine authored and anchao committed Feb 14, 2025
1 parent 5b9d535 commit 18c3e76
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libs/libc/modlib/modlib_bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ int modlib_bind(FAR struct module_s *modp,
ret = modlib_findsymtab(loadinfo);
if (ret < 0)
{
return ret;
goto errout_with_addrenv;
}

/* Process relocations in every allocated section */
Expand Down Expand Up @@ -989,7 +989,7 @@ int modlib_bind(FAR struct module_s *modp,

if (ret < 0)
{
return ret;
goto errout_with_addrenv;
}
}
else
Expand Down Expand Up @@ -1042,7 +1042,7 @@ int modlib_bind(FAR struct module_s *modp,

if (ret < 0)
{
return ret;
goto errout_with_addrenv;
}
}

Expand Down Expand Up @@ -1076,6 +1076,8 @@ int modlib_bind(FAR struct module_s *modp,
}
#endif

errout_with_addrenv:

#ifdef CONFIG_ARCH_ADDRENV
if (loadinfo->addrenv != NULL)
{
Expand Down

0 comments on commit 18c3e76

Please sign in to comment.