Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1562660

Re: [PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()

From James Hogan <james.hogan@imgtec.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
Date 2017-01-19 13:10 +0100
Message-ID <t1jHs-1mS-37@gated-at.bofh.it> (permalink)
References <t14Iq-91-13@gated-at.bofh.it> <t1hFE-8hK-25@gated-at.bofh.it> <t1i8F-jB-7@gated-at.bofh.it> <t1i8F-jB-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Jan 19, 2017 at 11:27:52AM +0100, Paolo Bonzini wrote:
> 
> 
> On 19/01/2017 11:20, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Thu, 19 Jan 2017 11:10:26 +0100
> > 
> > * Return directly after a call of the function "copy_from_user" failed
> >   in a case block.
> > 
> > * Delete the jump label "out" which became unnecessary with
> >   this refactoring.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> > 
> > V2:
> > A label was also removed at the end.
> > 
> >  arch/mips/kvm/mips.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> > 
> > diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> > index 06a60b19acfb..3534a0b9efed 100644
> > --- a/arch/mips/kvm/mips.c
> > +++ b/arch/mips/kvm/mips.c
> > @@ -1152,10 +1152,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl,
> >  		{
> >  			struct kvm_mips_interrupt irq;
> >  
> > -			r = -EFAULT;
> >  			if (copy_from_user(&irq, argp, sizeof(irq)))
> > -				goto out;
> > -
> > +				return -EFAULT;
> >  			kvm_debug("[%d] %s: irq: %d\n", vcpu->vcpu_id, __func__,
> >  				  irq.irq);
> >  
> > @@ -1165,17 +1163,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl,
> >  	case KVM_ENABLE_CAP: {
> >  		struct kvm_enable_cap cap;
> >  
> > -		r = -EFAULT;
> >  		if (copy_from_user(&cap, argp, sizeof(cap)))
> > -			goto out;
> > +			return -EFAULT;
> >  		r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
> >  		break;
> >  	}
> >  	default:
> >  		r = -ENOIOCTLCMD;
> >  	}
> > -
> > -out:
> >  	return r;
> >  }
> >  
> > 
> 
> Removing the label makes the patch worthwhile.
> 
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks Markus & Paolo. Looks better now. I'll apply for 4.11.

Cheers
James

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] MIPS: KVM: Return directly after a failed copy_from_user() in  kvm_arch_vcpu_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 21:10 +0100
  Re: [PATCH] MIPS: KVM: Return directly after a failed  copy_from_user() in kvm_arch_vcpu_ioctl() Paolo Bonzini <pbonzini@redhat.com> - 2017-01-19 11:00 +0100
    [PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user()  in kvm_arch_vcpu_ioctl() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-19 11:30 +0100
      Re: [PATCH v2] MIPS: KVM: Return directly after a failed  copy_from_user() in kvm_arch_vcpu_ioctl() Paolo Bonzini <pbonzini@redhat.com> - 2017-01-19 11:30 +0100
        Re: [PATCH v2] MIPS: KVM: Return directly after a failed  copy_from_user() in kvm_arch_vcpu_ioctl() James Hogan <james.hogan@imgtec.com> - 2017-01-19 13:10 +0100
  Re: [PATCH] MIPS: KVM: Return directly after a failed  copy_from_user() in kvm_arch_vcpu_ioctl() kbuild test robot <lkp@intel.com> - 2017-01-19 12:20 +0100

csiph-web