From 3ccff1938ec43efa1a4bb3f367d1985e35b91c0e Mon Sep 17 00:00:00 2001
From: Wenkai Lin <linwenkai6@hisilicon.com>
Date: Thu, 30 Dec 2021 20:34:52 +0800
Subject: [PATCH 26/28] uadk: sched: fix memory leak

sched_ctx and sched must be associated to
release the memory of sched_ctx

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
---
 wd_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/wd_sched.c b/wd_sched.c
index f97c15f..a85fd95 100644
--- a/wd_sched.c
+++ b/wd_sched.c
@@ -463,6 +463,7 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
 		goto err_out;
 	}
 
+	sched->h_sched_ctx = (handle_t)sched_ctx;
 	sched_info = sched_ctx->sched_info;
 
 	for (i = 0; i < numa_num; i++) {
@@ -482,7 +483,6 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
 	sched->sched_init = sched_table[sched_type].sched_init;
 	sched->pick_next_ctx = sched_table[sched_type].pick_next_ctx;
 	sched->poll_policy = sched_table[sched_type].poll_policy;
-	sched->h_sched_ctx = (handle_t)sched_ctx;
 
 	return sched;
 
-- 
2.31.1

