fs/overlayfs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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@kylinos.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;
}
--
2.40.1
… > Signed-off-by: huhai <huhai@kylinos.cn> > --- > fs/overlayfs/super.c | 2 +- … Should the personal name be usually different from an email identifier according to requirements of the Developer's Certificate of Origin? https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc2#n436 Regards, Markus
On Wed, Aug 20, 2025 at 11:29 AM huhai <hhtracer@gmail.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@kylinos.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.
© 2016 - 2025 Red Hat, Inc.