@@ -488,17 +488,6 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
488
488
return ret ;
489
489
}
490
490
491
- static ssize_t __vfs_write (struct file * file , const char __user * p ,
492
- size_t count , loff_t * pos )
493
- {
494
- if (file -> f_op -> write )
495
- return file -> f_op -> write (file , p , count , pos );
496
- else if (file -> f_op -> write_iter )
497
- return new_sync_write (file , p , count , pos );
498
- else
499
- return - EINVAL ;
500
- }
501
-
502
491
/* caller is responsible for file_start_write/file_end_write */
503
492
ssize_t __kernel_write (struct file * file , const void * buf , size_t count , loff_t * pos )
504
493
{
@@ -516,7 +505,12 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t
516
505
p = (__force const char __user * )buf ;
517
506
if (count > MAX_RW_COUNT )
518
507
count = MAX_RW_COUNT ;
519
- ret = __vfs_write (file , p , count , pos );
508
+ if (file -> f_op -> write )
509
+ ret = file -> f_op -> write (file , p , count , pos );
510
+ else if (file -> f_op -> write_iter )
511
+ ret = new_sync_write (file , p , count , pos );
512
+ else
513
+ ret = - EINVAL ;
520
514
set_fs (old_fs );
521
515
if (ret > 0 ) {
522
516
fsnotify_modify (file );
@@ -554,19 +548,23 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
554
548
return - EFAULT ;
555
549
556
550
ret = rw_verify_area (WRITE , file , pos , count );
557
- if (!ret ) {
558
- if (count > MAX_RW_COUNT )
559
- count = MAX_RW_COUNT ;
560
- file_start_write (file );
561
- ret = __vfs_write (file , buf , count , pos );
562
- if (ret > 0 ) {
563
- fsnotify_modify (file );
564
- add_wchar (current , ret );
565
- }
566
- inc_syscw (current );
567
- file_end_write (file );
551
+ if (ret )
552
+ return ret ;
553
+ if (count > MAX_RW_COUNT )
554
+ count = MAX_RW_COUNT ;
555
+ file_start_write (file );
556
+ if (file -> f_op -> write )
557
+ ret = file -> f_op -> write (file , buf , count , pos );
558
+ else if (file -> f_op -> write_iter )
559
+ ret = new_sync_write (file , buf , count , pos );
560
+ else
561
+ ret = - EINVAL ;
562
+ if (ret > 0 ) {
563
+ fsnotify_modify (file );
564
+ add_wchar (current , ret );
568
565
}
569
-
566
+ inc_syscw (current );
567
+ file_end_write (file );
570
568
return ret ;
571
569
}
572
570
0 commit comments