提交 26104c34 编写于 作者: T Tang Yizhou 提交者: Yang Yingliang

share_pool: Free newly generated id when failed

ascend inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4EUVI
CVE: NA

-------------------------------------------------

Free id at the end of sp_group_add_task when failed.
Benefits are below:
1. Less time to hold locks.
2. Avoid to forget freeing id in other error handling branches.
Signed-off-by: NTang Yizhou <tangyizhou@huawei.com>
Reviewed-by: NDing Tianhong <dingtianhong@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f1d48e52
......@@ -664,10 +664,8 @@ int sp_group_add_task(int pid, int spg_id)
rcu_read_unlock();
if (ret) {
if (id_newly_generated)
free_sp_group_id((unsigned int)spg_id);
up_write(&sp_group_sem);
goto out_unlock;
goto out_free_id;
}
/*
......@@ -695,10 +693,8 @@ int sp_group_add_task(int pid, int spg_id)
spg = find_or_alloc_sp_group(spg_id);
if (IS_ERR(spg)) {
ret = PTR_ERR(spg);
if (id_newly_generated)
free_sp_group_id((unsigned int)spg_id);
up_write(&sp_group_sem);
ret = PTR_ERR(spg);
goto out_put_mm;
}
......@@ -817,7 +813,9 @@ int sp_group_add_task(int pid, int spg_id)
mmput(mm);
out_put_task:
put_task_struct(tsk);
out_unlock:
out_free_id:
if (unlikely(ret) && id_newly_generated)
free_sp_group_id((unsigned int)spg_id);
return ret == 0 ? spg_id : ret;
}
EXPORT_SYMBOL_GPL(sp_group_add_task);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册