hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9206 ---------------------------------------- Add a sanity check to ensure the requested memory allocation size is greater than zero in vstream_hbm_alloc(). Attempting to allocate a zero-sized HBM region is invalid and should be rejected early. This patch returns -EINVAL if arg->vm_args.size is zero, preventing potential issues in the subsequent memory allocation logic. Fixes: dd2bb45851e5 ("xSched/dmem: introduce xsched_dmem_alloc()") Signed-off-by: Liu Kai <liukai284@huawei.com> --- kernel/xsched/vstream.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/xsched/vstream.c b/kernel/xsched/vstream.c index 1a30c205b366..e8173a7e10e2 100644 --- a/kernel/xsched/vstream.c +++ b/kernel/xsched/vstream.c @@ -640,6 +640,9 @@ static int vstream_hbm_alloc(struct vstream_args *arg) if (!dmem_cgroup_enabled()) return -EPERM; + if (arg->vm_args.size == 0) + return -EINVAL; + xcu_found = xcu_find(XCU_TYPE_XPU, arg->dev_id, arg->channel_id); if (!xcu_found) return -ENODEV; -- 2.34.1