[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxi3YSUsf1SOa9HA+8VFcFe1=5FKjZ-NvYnPaBZK2yOMwA@mail.gmail.com>
Date: Wed, 20 Aug 2025 11:33:04 +0200
From: Amir Goldstein <amir73il@...il.com>
To: huhai <hhtracer@...il.com>
Cc: miklos@...redi.hu, linux-unionfs@...r.kernel.org,
linux-kernel@...r.kernel.org, huhai <huhai@...inos.cn>
Subject: Re: [PATCH] ovl: only assign err on error path
On Wed, Aug 20, 2025 at 11:29 AM huhai <hhtracer@...il.com> 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@...inos.cn>
> ---
> 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.
Powered by blists - more mailing lists