Re: [PATCH] member: fix memory leak on error
From: Wang, Yipeng1 <hidden>
Date: 2017-12-22 18:33:12
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
From: Wang, Yipeng1 <hidden>
Date: 2017-12-22 18:33:12
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
-----Original Message----- From: Burakov, Anatoly Yep, i can see that now. Didn't think to look inside rte_member_free() :/ However, you're creating a race condition there - you're unlocking a tailq, and then locking (and unlocking) it again inside rte_member_free() - it probably needs _thread_unsafe() functions that you can call from behind the lock. --
Thank you Anatoly, I realize that rte_member_free does not do anything good here. As a fix, I think the following should work. Is there any other concern?
diff --git a/lib/librte_member/rte_member.c b/lib/librte_member/rte_member.c
index cc9ea84..25934e8 100644
--- a/lib/librte_member/rte_member.c
+++ b/lib/librte_member/rte_member.c@@ -192,7 +192,8 @@ rte_member_create(const struct rte_member_parameters *params) error_unlock_exit: rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); - rte_member_free(setsum); + rte_free(te); + rte_free(setsum); return NULL; }
Thank you!