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

From: Chenyuan Mi
Date: Tue Sep 07 2021 - 08:13:20 EST


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@xxxxxxxxxxxx>
Signed-off-by: Xiyu Yang <xiyuyang19@xxxxxxxxxxxx>
Signed-off-by: Xin Tan <tanxin.ctf@xxxxxxxxx>

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

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,
--
2.17.1