diff options
Diffstat (limited to 'fs/overlayfs/inode.c')
-rw-r--r-- | fs/overlayfs/inode.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 308379b2d0b2..21079d1ca2aa 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -343,31 +343,25 @@ static int ovl_dentry_open(struct dentry *dentry, struct file *file, | |||
343 | int err; | 343 | int err; |
344 | struct path realpath; | 344 | struct path realpath; |
345 | enum ovl_path_type type; | 345 | enum ovl_path_type type; |
346 | bool want_write = false; | ||
347 | 346 | ||
348 | type = ovl_path_real(dentry, &realpath); | 347 | type = ovl_path_real(dentry, &realpath); |
349 | if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) { | 348 | if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) { |
350 | want_write = true; | ||
351 | err = ovl_want_write(dentry); | 349 | err = ovl_want_write(dentry); |
352 | if (err) | 350 | if (err) |
353 | goto out; | 351 | return err; |
354 | 352 | ||
355 | if (file->f_flags & O_TRUNC) | 353 | if (file->f_flags & O_TRUNC) |
356 | err = ovl_copy_up_last(dentry, NULL, true); | 354 | err = ovl_copy_up_last(dentry, NULL, true); |
357 | else | 355 | else |
358 | err = ovl_copy_up(dentry); | 356 | err = ovl_copy_up(dentry); |
357 | ovl_drop_write(dentry); | ||
359 | if (err) | 358 | if (err) |
360 | goto out_drop_write; | 359 | return err; |
361 | 360 | ||
362 | ovl_path_upper(dentry, &realpath); | 361 | ovl_path_upper(dentry, &realpath); |
363 | } | 362 | } |
364 | 363 | ||
365 | err = vfs_open(&realpath, file, cred); | 364 | return vfs_open(&realpath, file, cred); |
366 | out_drop_write: | ||
367 | if (want_write) | ||
368 | ovl_drop_write(dentry); | ||
369 | out: | ||
370 | return err; | ||
371 | } | 365 | } |
372 | 366 | ||
373 | static const struct inode_operations ovl_file_inode_operations = { | 367 | static const struct inode_operations ovl_file_inode_operations = { |