Skip to content

Commit 165ea0d

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro: "Fix several places that screw up cleanups after failures halfway through opening a file (one open-coding filp_clone_open() and getting it wrong, two misusing alloc_file()). That part is -stable fodder from the 'work.open' branch. And Christoph's regression fix for uapi breakage in aio series; include/uapi/linux/aio_abi.h shouldn't be pulling in the kernel definition of sigset_t, the reason for doing so in the first place had been bogus - there's no need to expose struct __aio_sigset in aio_abi.h at all" * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: aio: don't expose __aio_sigset in uapi ocxlflash_getfile(): fix double-iput() on alloc_file() failures cxl_getfile(): fix double-iput() on alloc_file() failures drm_mode_create_lease_ioctl(): fix open-coded filp_clone_open()
2 parents f88a333 + 9ba546c commit 165ea0d

File tree

8 files changed

+14
-29
lines changed

8 files changed

+14
-29
lines changed

drivers/gpu/drm/drm_lease.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -553,24 +553,13 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
553553

554554
/* Clone the lessor file to create a new file for us */
555555
DRM_DEBUG_LEASE("Allocating lease file\n");
556-
path_get(&lessor_file->f_path);
557-
lessee_file = alloc_file(&lessor_file->f_path,
558-
lessor_file->f_mode,
559-
fops_get(lessor_file->f_inode->i_fop));
560-
556+
lessee_file = filp_clone_open(lessor_file);
561557
if (IS_ERR(lessee_file)) {
562558
ret = PTR_ERR(lessee_file);
563559
goto out_lessee;
564560
}
565561

566-
/* Initialize the new file for DRM */
567-
DRM_DEBUG_LEASE("Initializing the file with %p\n", lessee_file->f_op->open);
568-
ret = lessee_file->f_op->open(lessee_file->f_inode, lessee_file);
569-
if (ret)
570-
goto out_lessee_file;
571-
572562
lessee_priv = lessee_file->private_data;
573-
574563
/* Change the file to a master one */
575564
drm_master_put(&lessee_priv->master);
576565
lessee_priv->master = lessee;
@@ -588,9 +577,6 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
588577
DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n");
589578
return 0;
590579

591-
out_lessee_file:
592-
fput(lessee_file);
593-
594580
out_lessee:
595581
drm_master_put(&lessee);
596582

drivers/misc/cxl/api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ static struct file *cxl_getfile(const char *name,
103103
d_instantiate(path.dentry, inode);
104104

105105
file = alloc_file(&path, OPEN_FMODE(flags), fops);
106-
if (IS_ERR(file))
107-
goto err_dput;
106+
if (IS_ERR(file)) {
107+
path_put(&path);
108+
goto err_fs;
109+
}
108110
file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
109111
file->private_data = priv;
110112

111113
return file;
112114

113-
err_dput:
114-
path_put(&path);
115115
err_inode:
116116
iput(inode);
117117
err_fs:

drivers/scsi/cxlflash/ocxl_hw.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,14 @@ static struct file *ocxlflash_getfile(struct device *dev, const char *name,
134134
rc = PTR_ERR(file);
135135
dev_err(dev, "%s: alloc_file failed rc=%d\n",
136136
__func__, rc);
137-
goto err5;
137+
path_put(&path);
138+
goto err3;
138139
}
139140

140141
file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
141142
file->private_data = priv;
142143
out:
143144
return file;
144-
err5:
145-
path_put(&path);
146145
err4:
147146
iput(inode);
148147
err3:

fs/aio.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,11 @@ SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,
18961896
return ret;
18971897
}
18981898

1899+
struct __aio_sigset {
1900+
const sigset_t __user *sigmask;
1901+
size_t sigsetsize;
1902+
};
1903+
18991904
SYSCALL_DEFINE6(io_pgetevents,
19001905
aio_context_t, ctx_id,
19011906
long, min_nr,

fs/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
127127

128128
extern int open_check_o_direct(struct file *f);
129129
extern int vfs_open(const struct path *, struct file *, const struct cred *);
130-
extern struct file *filp_clone_open(struct file *);
131130

132131
/*
133132
* inode.c

include/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,6 +2420,7 @@ extern struct file *filp_open(const char *, int, umode_t);
24202420
extern struct file *file_open_root(struct dentry *, struct vfsmount *,
24212421
const char *, int, umode_t);
24222422
extern struct file * dentry_open(const struct path *, int, const struct cred *);
2423+
extern struct file *filp_clone_open(struct file *);
24232424
extern int filp_close(struct file *, fl_owner_t id);
24242425

24252426
extern struct filename *getname_flags(const char __user *, int, int *);

include/linux/syscalls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef _LINUX_SYSCALLS_H
1212
#define _LINUX_SYSCALLS_H
1313

14+
struct __aio_sigset;
1415
struct epoll_event;
1516
struct iattr;
1617
struct inode;

include/uapi/linux/aio_abi.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#include <linux/types.h>
3131
#include <linux/fs.h>
32-
#include <linux/signal.h>
3332
#include <asm/byteorder.h>
3433

3534
typedef __kernel_ulong_t aio_context_t;
@@ -110,10 +109,5 @@ struct iocb {
110109
#undef IFBIG
111110
#undef IFLITTLE
112111

113-
struct __aio_sigset {
114-
const sigset_t __user *sigmask;
115-
size_t sigsetsize;
116-
};
117-
118112
#endif /* __LINUX__AIO_ABI_H */
119113

0 commit comments

Comments
 (0)