MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
Subsystems (4)
PATCH 1/1 MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
From: Markus Elfring <[email protected]>
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.
--- arch/mips/kvm/mips.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
arch/mips/kvm/mips.c +2 -5
@@ -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 ; }
Signature · 1 line
2.11.0
Paolo Bonzini
maintainerQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 18 Jan 2017 20:43:41 +0100Return directly after a call of the function "
copy_from_user" failed in a case block.Signed-off-by Markus Elfring <[email protected]>
The "out" label is now unused, so you should remove it.
Paolo
Quoted 32 lines
--- arch/mips/kvm/mips.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)arch/mips/kvm/mips.c +2
-5@@ -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 ; }
PATCH v2 1/1 MIPS: KVM: Return directly after a failed copy_from_user() in kvm_arch_vcpu_ioctl()
From: Markus Elfring <[email protected]>
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.
---
V2:
A label was also removed at the end.
arch/mips/kvm/mips.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
arch/mips/kvm/mips.c +2 -7
@@ -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; }
Signature · 1 line
2.11.0
Quoted 44 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
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 <[email protected]>---
V2:
A label was also removed at the end.arch/mips/kvm/mips.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)arch/mips/kvm/mips.c +2
-5@@ -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);
arch/mips/kvm/mips.c long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, · line 1176
Quoted 10 lines
arch/mips/kvm/mips.c +0
-2break ; }default : r = -ENOIOCTLCMD ; } - -out:return r; }
Removing the label makes the patch worthwhile.
kbuild test robot
build botreproduce: 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…
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 <[email protected]>
:::::: CC: Ralf Baechle <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 60 lines · Paolo Bonzini
Quoted 44 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
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 <[email protected]>---
V2:
A label was also removed at the end.arch/mips/kvm/mips.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)arch/mips/kvm/mips.c +2
-5@@ -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);arch/mips/kvm/mips.c long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, · line 1176
Quoted 10 lines
arch/mips/kvm/mips.c +0
-2break ; }default : r = -ENOIOCTLCMD ; } - -out:return r; }Removing the label makes the patch worthwhile.
Quoted 1 line
Reviewed-by Paolo Bonzini <[email protected]>
Thanks Markus & Paolo. Looks better now. I'll apply for 4.11.
Cheers
James