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

tracing: Fix handle leak in TracepointProvider #12652

Merged
merged 1 commit into from Dec 30, 2016

Conversation

Projects
None yet
3 participants
@badone
Contributor

badone commented Dec 23, 2016

Silences Coverity 1397733

Signed-off-by: Brad Hubbard bhubbard@redhat.com

@@ -39,6 +39,7 @@ void TracepointProvider::verify_config(const struct md_config_t *conf) {
void *handle = dlopen(m_library.c_str(), RTLD_NOW);
if (handle != NULL) {
m_enabled = true;
free(handle);

This comment has been minimized.

@xiexingguo

xiexingguo Dec 24, 2016

Member

dlclose(handle)?

This comment has been minimized.

@badone

badone Dec 24, 2016

Contributor

@xiexingguo that would unload the shared object and I'm not sure that's the intention here? You're right though that free is probably not the way to go in hindsight. @dillaman could we get your opinion here?

This comment has been minimized.

@badone

badone Dec 24, 2016

Contributor

Perhaps making the handle a member and calling dlclose in the destructor?

@badone

This comment has been minimized.

Contributor

badone commented Dec 24, 2016

I've changed this to be more of an RAII approach which I think is better. @dillaman still like your opinion when you are around.

void *handle = dlopen(m_library.c_str(), RTLD_NOW);
if (handle != NULL) {
m_handle = dlopen(m_library.c_str(), RTLD_NOW);
if (m_handle != NULL) {

This comment has been minimized.

@dillaman

dillaman Dec 28, 2016

Contributor

Nit: I would now eliminate the m_enabled member variable and just use m_handle != nullptr to determine if it's enabled.

This comment has been minimized.

@badone

badone Dec 29, 2016

Contributor

Yes, more like @dragonylffly solution in #12673 Agreed, it's a good idea.

tracing: Fix handle leak in TracepointProvider
Silences Coverity 1397733

Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
@badone

This comment has been minimized.

Contributor

badone commented Dec 30, 2016

Updated. Many thanks to @dragonylffly for his contribution.

@dillaman

lgtm

@badone badone merged commit 874aed6 into ceph:master Dec 30, 2016

3 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodifed Submodules submodules for project are unmodified
Details
default Build finished.
Details

@badone badone deleted the badone:wip-coverity-TracepointProvider branch Dec 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment