From: Wang ShaoBo bobo.shaobowang@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I3U0YN CVE: NA
-------------------------------------------------
We add label out_free_rdtgrp for handling error branch when it happened before rmid and closid allocation, in case of reusing rdtgrp after freeing.
Fixes: 27cfa75ec350 ("arm64/mpam: Remap reqpartid,pmg to rmid and intpartid to closid") Signed-off-by: Wang ShaoBo bobo.shaobowang@huawei.com Reviewed-by: Jian Cheng cj.chengjian@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- fs/resctrlfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/resctrlfs.c b/fs/resctrlfs.c index df47b105609b9..2f393edd68d64 100644 --- a/fs/resctrlfs.c +++ b/fs/resctrlfs.c @@ -619,7 +619,7 @@ static int mkdir_resctrl_prepare(struct kernfs_node *parent_kn, ret = closid_alloc(); if (ret < 0) { rdt_last_cmd_puts("out of CLOSIDs\n"); - goto out_unlock; + goto out_free_rdtgrp; } rdtgrp->closid.intpartid = ret; } @@ -689,10 +689,11 @@ static int mkdir_resctrl_prepare(struct kernfs_node *parent_kn, kernfs_remove(rdtgrp->kn); out_free_rmid: rmid_free(rdtgrp->mon.rmid); - kfree(rdtgrp); out_free_closid: if (rdtgrp->type == RDTCTRL_GROUP) closid_free(rdtgrp->closid.intpartid); +out_free_rdtgrp: + kfree(rdtgrp); out_unlock: resctrl_group_kn_unlock(prgrp_kn); return ret;