diff mbox series

test_objagg: Fix objagg and hints refcount leak when create objagg2 failed

Message ID 20210907121248.28236-1-cymi20@fudan.edu.cn
State New
Headers show
Series test_objagg: Fix objagg and hints refcount leak when create objagg2 failed | expand

Commit Message

Chenyuan Mi Sept. 7, 2021, 12:12 p.m. UTC
The reference couting issue happens in one exception handling path of
test_hints_case(). When failing to create objagg2, the function forgets
to decrease the refcount of both objagg and hints, causing a refcount leak.

Fix this issue by jumping to the label "err_check_expect_hints_stats".

Signed-off-by: Chenyuan Mi <cymi20@fudan.edu.cn>
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>

---
 lib/test_objagg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/test_objagg.c b/lib/test_objagg.c
index da137939a410..a7ee118c58aa 100644
--- a/lib/test_objagg.c
+++ b/lib/test_objagg.c
@@ -954,7 +954,8 @@  static int test_hints_case(const struct hints_case *hints_case)
 
 	objagg2 = objagg_create(&delta_ops, hints, &world2);
 	if (IS_ERR(objagg2))
-		return PTR_ERR(objagg2);
+		err = PTR_ERR(objagg2);
+		goto err_check_expect_hints_stats
 
 	for (i = 0; i < hints_case->key_ids_count; i++) {
 		objagg_obj = world_obj_get(&world2, objagg2,