From: Zicheng Qu <quzicheng@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/10133 ------------------------ vstream_hbm_free() returned -ENOENT when no context was found for the current task, turning what should be a no-op free into an error. Align it with vstream_hbm_cleanup(): skip the free when there is no context and return success. Also initialise ret so that the early-exit path returns a defined value. Fixes: f6d8e9b654d6 ("xSched/dmem: introduce xsched_dmem_free()") Signed-off-by: Zicheng Qu <quzicheng@huawei.com> Signed-off-by: Tang Hui <tanghui20@huawei.com> --- kernel/xsched/vstream.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/xsched/vstream.c b/kernel/xsched/vstream.c index e7574236b363e..57b5a1746c289 100644 --- a/kernel/xsched/vstream.c +++ b/kernel/xsched/vstream.c @@ -680,7 +680,7 @@ static int vstream_hbm_free(struct vstream_args *arg) { struct xsched_cu *xcu_found; struct xsched_context *ctx; - int ret; + int ret = 0; if (!dmem_cgroup_enabled()) return -EPERM; @@ -695,14 +695,11 @@ static int vstream_hbm_free(struct vstream_args *arg) kref_get(&ctx->kref); mutex_unlock(&xcu_found->ctx_list_lock); - if (!ctx) { - XSCHED_ERR("Failed to find a context for HBM free"); - return -ENOENT; + if (ctx) { + ret = xsched_dmem_free(ctx, arg); + kref_put(&ctx->kref, xsched_task_free); } - ret = xsched_dmem_free(ctx, arg); - kref_put(&ctx->kref, xsched_task_free); - return ret; } -- 2.34.1