linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
@ 2017-01-18 19:52 SF Markus Elfring
  2017-01-19  9:50 ` Paolo Bonzini
  2017-01-19 11:13 ` [PATCH] " kbuild test robot
  0 siblings, 2 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-01-18 19:52 UTC (permalink / raw)
  To: kvm, linux-mips, James Hogan, Paolo Bonzini,
	Radim Krčmář,
	Ralf Bächle
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 20:43:41 +0100

Return directly after a call of the function "copy_from_user" failed
in a case block.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/mips/kvm/mips.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 06a60b19acfb..1dad78f74e8c 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,9 +1163,8 @@ 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;
 	}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
  2017-01-18 19:52 [PATCH] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl() SF Markus Elfring
@ 2017-01-19  9:50 ` Paolo Bonzini
  2017-01-19 10:20   ` [PATCH v2] " SF Markus Elfring
  2017-01-19 11:13 ` [PATCH] " kbuild test robot
  1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2017-01-19  9:50 UTC (permalink / raw)
  To: SF Markus Elfring, kvm, linux-mips, James Hogan,
	Radim Krčmář,
	Ralf Bächle
  Cc: LKML, kernel-janitors



On 18/01/2017 20:52, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 18 Jan 2017 20:43:41 +0100
> 
> Return directly after a call of the function "copy_from_user" failed
> in a case block.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

The "out" label is now unused, so you should remove it.

Paolo

> ---
>  arch/mips/kvm/mips.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> index 06a60b19acfb..1dad78f74e8c 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,9 +1163,8 @@ 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;
>  	}
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
  2017-01-19  9:50 ` Paolo Bonzini
@ 2017-01-19 10:20   ` SF Markus Elfring
  2017-01-19 10:27     ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2017-01-19 10:20 UTC (permalink / raw)
  To: kvm, linux-mips, James Hogan, Paolo Bonzini,
	Radim Krčmář,
	Ralf Bächle
  Cc: LKML, kernel-janitors

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;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
  2017-01-19 10:20   ` [PATCH v2] " SF Markus Elfring
@ 2017-01-19 10:27     ` Paolo Bonzini
  2017-01-19 12:08       ` James Hogan
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2017-01-19 10:27 UTC (permalink / raw)
  To: SF Markus Elfring, kvm, linux-mips, James Hogan,
	Radim Krčmář,
	Ralf Bächle
  Cc: LKML, kernel-janitors



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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
  2017-01-18 19:52 [PATCH] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl() SF Markus Elfring
  2017-01-19  9:50 ` Paolo Bonzini
@ 2017-01-19 11:13 ` kbuild test robot
  1 sibling, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2017-01-19 11:13 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kbuild-all, kvm, linux-mips, James Hogan, Paolo Bonzini,
	Radim Krčmář,
	Ralf Bächle, LKML, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2216 bytes --]

Hi Markus,

[auto build test ERROR on kvm/linux-next]
[also build test ERROR on v4.10-rc4 next-20170119]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/MIPS-KVM-Return-directly-after-a-failed-copy_from_user-in-kvm_arch_vcpu_ioctl/20170119-154855
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: mips-malta_kvm_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   arch/mips/kvm/mips.c: In function 'kvm_arch_vcpu_ioctl':
>> arch/mips/kvm/mips.c:1175:1: error: label 'out' defined but not used [-Werror=unused-label]
    out:
    ^~~
   cc1: all warnings being treated as errors

vim +/out +1175 arch/mips/kvm/mips.c

5fafd8748 arch/mips/kvm/mips.c     James Hogan 2014-12-08  1169  		break;
5fafd8748 arch/mips/kvm/mips.c     James Hogan 2014-12-08  1170  	}
669e846e6 arch/mips/kvm/kvm_mips.c Sanjay Lal  2012-11-21  1171  	default:
4c73fb2b0 arch/mips/kvm/kvm_mips.c David Daney 2013-05-23  1172  		r = -ENOIOCTLCMD;
669e846e6 arch/mips/kvm/kvm_mips.c Sanjay Lal  2012-11-21  1173  	}
669e846e6 arch/mips/kvm/kvm_mips.c Sanjay Lal  2012-11-21  1174  
669e846e6 arch/mips/kvm/kvm_mips.c Sanjay Lal  2012-11-21 @1175  out:
669e846e6 arch/mips/kvm/kvm_mips.c Sanjay Lal  2012-11-21  1176  	return r;
669e846e6 arch/mips/kvm/kvm_mips.c Sanjay Lal  2012-11-21  1177  }
669e846e6 arch/mips/kvm/kvm_mips.c Sanjay Lal  2012-11-21  1178  

:::::: The code at line 1175 was first introduced by commit
:::::: 669e846e6c4e13f16d7418973609931e362cb16a KVM/MIPS32: MIPS arch specific APIs for KVM

:::::: TO: Sanjay Lal <sanjayl@kymasys.com>
:::::: CC: Ralf Baechle <ralf@linux-mips.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 18266 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
  2017-01-19 10:27     ` Paolo Bonzini
@ 2017-01-19 12:08       ` James Hogan
  0 siblings, 0 replies; 6+ messages in thread
From: James Hogan @ 2017-01-19 12:08 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: SF Markus Elfring, kvm, linux-mips, Radim Krčmář,
	Ralf Bächle, LKML, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1871 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-19 12:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 19:52 [PATCH] MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl() SF Markus Elfring
2017-01-19  9:50 ` Paolo Bonzini
2017-01-19 10:20   ` [PATCH v2] " SF Markus Elfring
2017-01-19 10:27     ` Paolo Bonzini
2017-01-19 12:08       ` James Hogan
2017-01-19 11:13 ` [PATCH] " kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).