Re: [PATCH] fs: fuse: dax: set fc->dax to NULL in fuse_dax_conn_free()

From: Miklos Szeredi
Date: Mon Dec 04 2023 - 04:18:32 EST


On Fri, 1 Dec 2023 at 20:08, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote:
>
> On Fri, Dec 01, 2023 at 10:42:53AM +0800, Hangyu Hua wrote:

> > I think setting fc->dax to NULL keeps the memory allocation and release
> > functions together in fuse_fill_super_common more readable. What do you
> > think?
>
> I agree with this. fuse_fill_super_common() calls fuse_dax_conn_alloc()
> which in-turn initializes fc->dax. If fuse_fill_super_common() fails
> later after calling fuse_dax_conn_alloc(), then cleanup of fc->dax
> and other associated stuff in same function makes sense.
>
> As a code reader I would like to know how fc->dax is being freed in
> case of error and its right there in the error path (err_free_dax:).
>
> I think I set the fc->dax upon initialization. Upon failure I freed
> the data structures but did not set fc->dax back to NULL.
>
> To me, this patch looks reasonable.
>
> Acked-by: Vivek Goyal <vgoyal@xxxxxxxxxx>

Applied, thanks.

The patch is clearly correct, so I have not major issue with it. It
just bothers me a little that we have two cleanup instances when we
only need one, but I bow to the opinion of the majority.

Thanks,
Miklos