File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ static int kvm_pch_pic_regs_access(struct kvm_device *dev,
348348 struct kvm_device_attr * attr ,
349349 bool is_write )
350350{
351+ char buf [8 ];
351352 int addr , offset , len = 8 , ret = 0 ;
352353 void __user * data ;
353354 void * p = NULL ;
@@ -397,17 +398,23 @@ static int kvm_pch_pic_regs_access(struct kvm_device *dev,
397398 return - EINVAL ;
398399 }
399400
400- spin_lock (& s -> lock );
401- /* write or read value according to is_write */
402401 if (is_write ) {
403- if (copy_from_user (p , data , len ))
404- ret = - EFAULT ;
405- } else {
406- if (copy_to_user (data , p , len ))
407- ret = - EFAULT ;
402+ if (copy_from_user (buf , data , len ))
403+ return - EFAULT ;
408404 }
405+
406+ spin_lock (& s -> lock );
407+ if (is_write )
408+ memcpy (p , buf , len );
409+ else
410+ memcpy (buf , p , len );
409411 spin_unlock (& s -> lock );
410412
413+ if (!is_write ) {
414+ if (copy_to_user (data , buf , len ))
415+ return - EFAULT ;
416+ }
417+
411418 return ret ;
412419}
413420
You can’t perform that action at this time.
0 commit comments