hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9206 ---------------------------------------- Replace hardcoded -EINVAL returns with the actual error codes generated during execution. This ensures that callers receive precise failure reasons, such as distinguishing between an invalid argument and a missing device (-ENODEV) in vstream_hbm_alloc, or preserving the original failure reason from xsched_xse_init(). Fixes: 8dde1f2e6bf6 ("xsched: Introduce vstream management") Fixes: dd2bb45851e5 ("xSched/dmem: introduce xsched_dmem_alloc()") Signed-off-by: Liu Kai <liukai284@huawei.com> --- kernel/xsched/vstream.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/xsched/vstream.c b/kernel/xsched/vstream.c index bf9c047dbc79..6ece03d3ff22 100644 --- a/kernel/xsched/vstream.c +++ b/kernel/xsched/vstream.c @@ -245,7 +245,7 @@ static int alloc_ctx_from_vstream(struct vstream_info *vstream_info, XSCHED_ERR("Fail to initialize XSE for context @ %s\n", __func__); kfree(*ctx); - return -EINVAL; + return ret; } list_add(&(*ctx)->ctx_node, &xcu->ctx_list); @@ -415,10 +415,8 @@ static int sqcq_alloc(struct vstream_args *arg) vstream->task_type = arg->task_type; ret = vstream_bind_to_xcu(vstream); - if (ret < 0) { - ret = -EINVAL; + if (ret != 0) goto out_err_vstream_free; - } /* Allocates vstream's SQ and CQ memory on a XCU for processing. */ params.group = vstream->xcu->group; @@ -645,7 +643,7 @@ static int vstream_hbm_alloc(struct vstream_args *arg) xcu_found = xcu_find(XCU_TYPE_XPU, arg->dev_id, arg->channel_id); if (!xcu_found) - return -EINVAL; + return -ENODEV; /* it will either allocate or find a context */ mutex_lock(&xcu_found->ctx_list_lock); -- 2.34.1