Re: [PATCH] nvdimm-btt: simplify code with the scope based resource management

From: dinghao . liu
Date: Thu Dec 14 2023 - 02:56:59 EST


> > It's a little strange that we do not check super immediately after allocation.
> > How about this:
> >
> > static int discover_arenas(struct btt *btt)
> > {
> > int ret = 0;
> > struct arena_info *arena;
> > - struct btt_sb *super;
> > size_t remaining = btt->rawsize;
> > u64 cur_nlba = 0;
> > size_t cur_off = 0;
> > int num_arenas = 0;
> >
> > - super = kzalloc(sizeof(*super), GFP_KERNEL);
> > + struct btt_sb *super __free(kfree) =
> > + kzalloc(sizeof(*super), GFP_KERNEL);
> > if (!super)
> > return -ENOMEM;
> >
> > while (remaining) {
> >
>
> That's fine by me

I will resend a new patch soon, thanks!

Regards,
Dinghao