diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index ddcf8d3a83bfd97b4367c24d8a83146d56cd7add..51152858ff214be30047e3aa489a828cc8f335ea 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1338,14 +1338,23 @@ static int ovl_get_lower_layers(struct super_block *sb, struct ovl_fs *ofs, if (err < 0) goto out; + /* + * Check if lower root conflicts with this overlay layers before + * checking if it is in-use as upperdir/workdir of "another" + * mount, because we do not bother to check in ovl_is_inuse() if + * the upperdir/workdir is in fact in-use by our + * upperdir/workdir. + */ err = ovl_setup_trap(sb, stack[i].dentry, &trap, "lowerdir"); if (err) goto out; if (ovl_is_inuse(stack[i].dentry)) { err = ovl_report_in_use(ofs, "lowerdir"); - if (err) + if (err) { + iput(trap); goto out; + } } mnt = clone_private_mount(&stack[i]);