Skip to content

Commit b4e7a7a

Browse files
author
Al Viro
committed
drm_mode_create_lease_ioctl(): fix open-coded filp_clone_open()
Failure of ->open() should *not* be followed by fput(). Fixed by using filp_clone_open(), which gets the cleanups right. Cc: [email protected] Acked-by: Linus Torvalds <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 877f919 commit b4e7a7a

File tree

3 files changed

+2
-16
lines changed

3 files changed

+2
-16
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

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
@@ -2422,6 +2422,7 @@ extern struct file *filp_open(const char *, int, umode_t);
24222422
extern struct file *file_open_root(struct dentry *, struct vfsmount *,
24232423
const char *, int, umode_t);
24242424
extern struct file * dentry_open(const struct path *, int, const struct cred *);
2425+
extern struct file *filp_clone_open(struct file *);
24252426
extern int filp_close(struct file *, fl_owner_t id);
24262427

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

0 commit comments

Comments
 (0)