You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "Donny9 (via GitHub)" <gi...@apache.org> on 2023/09/18 03:33:09 UTC
[GitHub] [nuttx] Donny9 opened a new pull request, #10676: libc/modlib: fix minor issue about modlib
Donny9 opened a new pull request, #10676:
URL: https://github.com/apache/nuttx/pull/10676
## Summary
1. libs/modlib: close fd when error happen
2. libs/modlib: avoid seeking in each reading
3. libs/modlib: avoid double free when call modlib_unload with erro
4. libc/mod: fix minor issue about description
## Impact
## Testing
daily test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] anchao commented on a diff in pull request #10676: libc/modlib: fix minor issue about modlib
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #10676:
URL: https://github.com/apache/nuttx/pull/10676#discussion_r1328244951
##########
libs/libc/modlib/modlib_loadhdrs.c:
##########
@@ -116,7 +116,6 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->phdr = (FAR Elf_Phdr *)lib_malloc(phdrsize);
if (!loadinfo->phdr)
{
- lib_free(loadinfo->shdr);
Review Comment:
keep the free call and assigning the pointer to null
##########
libs/libc/modlib/modlib_loadhdrs.c:
##########
@@ -129,8 +128,6 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
if (ret < 0)
{
berr("ERROR: Failed to read program header table: %d\n", ret);
- lib_free(loadinfo->phdr);
- lib_free(loadinfo->shdr);
Review Comment:
keep the free call and assigning the pointer to null
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] Donny9 commented on a diff in pull request #10676: libc/modlib: fix minor issue about modlib
Posted by "Donny9 (via GitHub)" <gi...@apache.org>.
Donny9 commented on code in PR #10676:
URL: https://github.com/apache/nuttx/pull/10676#discussion_r1331028629
##########
libs/libc/modlib/modlib_loadhdrs.c:
##########
@@ -116,7 +116,6 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->phdr = (FAR Elf_Phdr *)lib_malloc(phdrsize);
if (!loadinfo->phdr)
{
- lib_free(loadinfo->shdr);
Review Comment:
Yes, resources should be released internally, but I look at the usage of libc/dlfcn and sched/module. All resource releases are placed in modlib_uninitialize and modlib_unload. It seems that we can make less changes and reuse some code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] Donny9 commented on a diff in pull request #10676: libc/modlib: fix minor issue about modlib
Posted by "Donny9 (via GitHub)" <gi...@apache.org>.
Donny9 commented on code in PR #10676:
URL: https://github.com/apache/nuttx/pull/10676#discussion_r1328440559
##########
libs/libc/modlib/modlib_loadhdrs.c:
##########
@@ -116,7 +116,6 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->phdr = (FAR Elf_Phdr *)lib_malloc(phdrsize);
if (!loadinfo->phdr)
{
- lib_free(loadinfo->shdr);
Review Comment:
@anchao The reason why I removed it is because there is no free action in lines 99, 111 of this file, Looks like modlib_unload is handled better. ditto.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 merged pull request #10676: libc/modlib: fix minor issue about modlib
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #10676:
URL: https://github.com/apache/nuttx/pull/10676
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] anchao commented on a diff in pull request #10676: libc/modlib: fix minor issue about modlib
Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on code in PR #10676:
URL: https://github.com/apache/nuttx/pull/10676#discussion_r1328457786
##########
libs/libc/modlib/modlib_loadhdrs.c:
##########
@@ -116,7 +116,6 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
loadinfo->phdr = (FAR Elf_Phdr *)lib_malloc(phdrsize);
if (!loadinfo->phdr)
{
- lib_free(loadinfo->shdr);
Review Comment:
1. modlib_loadhdrs() is a public function. All resources are better managed inside the function. If the call fails from internal, it is better to destroy by this function.
2. I don't think delay free to modlib_unload() is a good practice, it will increase the lifetime of the memory being occupied
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org