Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible memory leak in error path when elf notes are backed by a memfd path #2320

Merged
merged 1 commit into from
Apr 19, 2019

Conversation

dalehamel
Copy link
Member

As @palmtenor points out, #2314 (comment), the original PR misses freeing the memory that it allocates for a string on the error path (where the directory listing fails) resulting in a potential memory leak.

I had considered just using a separate buffer for the directory string, but decided to malloc it so I could reuse the buffer for building the full path while still retaining access to the string. If there's a reason to prefer that approach I can modify this PR according, which would eliminate the need to bother with freeing this string buffer as it would be stack-allocated instead.

@palmtenor
Copy link
Member

[buildbot, ok to test]

@dalehamel dalehamel changed the title Free local string variable on error path when parsing elf notes from memfd-backed file Fix possible memory leak in error path when elf notes are backed by a memfd path Apr 18, 2019
@yonghong-song
Copy link
Collaborator

[buildbot, test this please]

@palmtenor palmtenor merged commit 440268e into iovisor:master Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants