Re: [PATCH] ovl: only assign err on error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 20, 2025 at 11:29 AM huhai <hhtracer@xxxxxxxxx> wrote:
>
> In ovl_get_upper(), the result of clone_private_mount() was
> unconditionally assigned to 'err' using PTR_ERR(), even when the
> returned 'upper_mnt' was valid. This assignment is unnecessary in
> the success path and can be avoided.
>
> Move the 'err = PTR_ERR(upper_mnt)' assignment inside the
> IS_ERR(upper_mnt) branch so that 'err' is only set when an
> error actually occurred.
>
> No functional change intended.
>
> Signed-off-by: huhai <huhai@xxxxxxxxxx>
> ---
>  fs/overlayfs/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index df85a76597e9..a29ce0bce6a5 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -512,9 +512,9 @@ static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
>                 goto out;
>
>         upper_mnt = clone_private_mount(upperpath);
> -       err = PTR_ERR(upper_mnt);
>         if (IS_ERR(upper_mnt)) {
>                 pr_err("failed to clone upperpath\n");
> +               err = PTR_ERR(upper_mnt);
>                 goto out;
>         }
>

NAK.

No good reason to make this change.
To be clear,
"This assignment is unnecessary in the success path and can be avoided"
is not a good enough reason.

Thanks,
Amir.





[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux