RE: [PATCH v2] fs/resctrl: Optimize code in rdt_get_tree()

From: Shaopeng Tan (Fujitsu)
Date: Fri Jul 18 2025 - 01:56:25 EST


Hello Koba Ko,

>
> Thanks
> Reviewed-by: Koba Ko <kobak@xxxxxxxxxx>

Thanks for your review.

> On 6/23/25 15:50, Shaopeng Tan wrote:
> > External email: Use caution opening links or attachments
> >
> >
> > schemata_list_destroy() has to be called if schemata_list_create() fails.
> >
> > rdt_get_tree() calls schemata_list_destroy() in two different ways:
> > directly if schemata_list_create() itself fails and on the exit path
> > via the out_schemata_free goto label.
> >
> > Remove schemata_list_destroy() call on schemata_list_create() failure.
> > Use existing out_schemata_free goto label instead.
> >
> > Signed-off-by: Shaopeng Tan <tan.shaopeng@xxxxxxxxxxxxxx>
> > Reviewed-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
> > Reviewed-by: James Morse <james.morse@xxxxxxx>
> > ---
> > fs/resctrl/rdtgroup.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index
> > 77d08229d855..5f0b7cfa1cc2 100644
> > --- a/fs/resctrl/rdtgroup.c
> > +++ b/fs/resctrl/rdtgroup.c
> > @@ -2608,10 +2608,8 @@ static int rdt_get_tree(struct fs_context *fc)
> > goto out_root;
> >
> > ret = schemata_list_create();
> > - if (ret) {
> > - schemata_list_destroy();
> > - goto out_ctx;
> > - }
> > + if (ret)
> > + goto out_schemata_free;
> >
> > ret = closid_init();
> > if (ret)
> > @@ -2683,7 +2681,6 @@ static int rdt_get_tree(struct fs_context *fc)
> > closid_exit();
> > out_schemata_free:
> > schemata_list_destroy();
> > -out_ctx:
> > rdt_disable_ctx();
> > out_root:
> > rdtgroup_destroy_root();
> > --
> > 2.43.5
> >