Re: ksmbd: Use common error handling code in ksmbd_vfs_path_lookup()

From: NeilBrown
Date: Sat Oct 04 2025 - 07:16:39 EST


On Sat, 04 Oct 2025, Markus Elfring wrote:
> …> - declare struct path path __free(path_-put) = {};
> …> return_path->dentry = no_free_ptr(path.dentry);
> > return_path->mnt = no_free_ptr(path.mnt);
> > return 0;
> >
> > This is based on the pattern in kern_path_parent() and
> > __start_removing_path().
>
> Do you propose that affected software components may benefit more from
> the application of scope-based resource management?
> https://elixir.bootlin.com/linux/v6.17/source/include/linux/path.h#L22-L28

Exactly. It doesn't suit every case, but if you are going to make
changes to the exit paths of a function, I think it is worth
considering if scope-based code will work well for the particular
function.

Since v6.17 there has already been a net increase of 167 uses of __free
(though some might be in comments....) and 1902 more uses for guard().
So at least some people think it is a good idea.

NeilBrown