@@ -261,19 +261,20 @@ static int do_handle_to_path(struct file_handle *handle, struct path *path,
261
261
{
262
262
int handle_dwords ;
263
263
struct vfsmount * mnt = ctx -> root .mnt ;
264
+ struct dentry * dentry ;
264
265
265
266
/* change the handle size to multiple of sizeof(u32) */
266
267
handle_dwords = handle -> handle_bytes >> 2 ;
267
- path -> dentry = exportfs_decode_fh_raw (mnt ,
268
- (struct fid * )handle -> f_handle ,
269
- handle_dwords , handle -> handle_type ,
270
- ctx -> fh_flags ,
271
- vfs_dentry_acceptable , ctx );
272
- if (IS_ERR_OR_NULL (path -> dentry )) {
273
- if (path -> dentry == ERR_PTR (- ENOMEM ))
268
+ dentry = exportfs_decode_fh_raw (mnt , (struct fid * )handle -> f_handle ,
269
+ handle_dwords , handle -> handle_type ,
270
+ ctx -> fh_flags , vfs_dentry_acceptable ,
271
+ ctx );
272
+ if (IS_ERR_OR_NULL (dentry )) {
273
+ if (dentry == ERR_PTR (- ENOMEM ))
274
274
return - ENOMEM ;
275
275
return - ESTALE ;
276
276
}
277
+ path -> dentry = dentry ;
277
278
path -> mnt = mntget (mnt );
278
279
return 0 ;
279
280
}
@@ -398,29 +399,23 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh,
398
399
int open_flag )
399
400
{
400
401
long retval = 0 ;
401
- struct path path ;
402
+ struct path path __free ( path_put ) = {} ;
402
403
struct file * file ;
403
- int fd ;
404
404
405
405
retval = handle_to_path (mountdirfd , ufh , & path , open_flag );
406
406
if (retval )
407
407
return retval ;
408
408
409
- fd = get_unused_fd_flags (open_flag );
410
- if (fd < 0 ) {
411
- path_put (& path );
409
+ CLASS (get_unused_fd , fd )(O_CLOEXEC );
410
+ if (fd < 0 )
412
411
return fd ;
413
- }
412
+
414
413
file = file_open_root (& path , "" , open_flag , 0 );
415
- if (IS_ERR (file )) {
416
- put_unused_fd (fd );
417
- retval = PTR_ERR (file );
418
- } else {
419
- retval = fd ;
420
- fd_install (fd , file );
421
- }
422
- path_put (& path );
423
- return retval ;
414
+ if (IS_ERR (file ))
415
+ return PTR_ERR (file );
416
+
417
+ fd_install (fd , file );
418
+ return take_fd (fd );
424
419
}
425
420
426
421
/**
0 commit comments