Skip to contentSkip to conversation

libmultipath: fix memory leak in checker_cleanup_thread

PATCH In review lixiaokeng 3 participants 3 messages Apr 9, 2021 – Apr 12, 2021 Device mapper

lore
Share & tools
lore

lixiaokeng

author
#0 lore raw

PATCH 1/1 libmultipath: fix memory leak in checker_cleanup_thread

If checker_cleanup_thread is called after cleanup_checkers, the checker_class will not be freed.

Here, we use free_checker_class instead of checker_class_unref in checker_cleanup_thread.

---
 libmultipath/checkers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/checkers.c +1 -1
index 2dd9915d..7cc80f0b 100644
@@ -368,7 +368,7 @@ static void checker_cleanup_thread(void *arg)
 {
 	struct checker_class *cls = arg;
 
-	(void)checker_class_unref(cls);
+	(void)free_checker_class(cls);
 	rcu_unregister_thread();
 }
 
Signature · 4 lines
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · lixiaokeng

If checker_cleanup_thread is called after cleanup_checkers, the checker_class will not be freed.

Here, we use free_checker_class instead of checker_class_unref in checker_cleanup_thread.

---
 libmultipath/checkers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/checkers.c +0 -0
index 2dd9915d..7cc80f0b 100644

libmultipath/checkers.c static void checker_cleanup_thread(void *arg) · line 374

Quoted 8 lines
libmultipath/checkers.c +1 -1
@@ -368,7 +368,7 @@ static void checker_cleanup_thread(void *arg)
 {
 	struct checker_class *cls = arg;
 
-	(void)checker_class_unref(cls);
+	(void)free_checker_class(cls);
 	rcu_unregister_thread();
 }
 

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

Reviewed-by
#2 lore raw
Quoted 20 lines · Benjamin Marzinski
Quoted 19 lines · lixiaokeng

If checker_cleanup_thread is called after cleanup_checkers, the checker_class will not be freed.

Here, we use free_checker_class instead of checker_class_unref in checker_cleanup_thread.

---
 libmultipath/checkers.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/checkers.c +0 -0
index 2dd9915d..7cc80f0b 100644
@@ -368,7 +368,7 @@ static void checker_cleanup_thread(void *arg)
  {
         struct checker_class *cls = arg;
 
Quoted 9 lines

libmultipath/checkers.c static void checker_cleanup_thread(void *arg) · line 374

Quoted 6 lines
libmultipath/checkers.c +1 -1
-       (void)checker_class_unref(cls);
+       (void)free_checker_class(cls);
         rcu_unregister_thread();
  }
 

Nit: The cast to void is wrong, as free_checker_class() is a void function anyway. I'll take the freedom to remove it when I apply this to the "queue" branch.

Thanks,
Martin

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel