From patchwork Sun Jan 22 18:13:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9531285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EEF2D60431 for ; Sun, 22 Jan 2017 18:14:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E193127FA6 for ; Sun, 22 Jan 2017 18:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D61AA27FB1; Sun, 22 Jan 2017 18:14:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A03427FA6 for ; Sun, 22 Jan 2017 18:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbdAVSON (ORCPT ); Sun, 22 Jan 2017 13:14:13 -0500 Received: from mout.web.de ([212.227.17.12]:64788 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751566AbdAVSOI (ORCPT ); Sun, 22 Jan 2017 13:14:08 -0500 Received: from [192.168.1.2] ([78.48.136.24]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LjJH1-1bxxQo28Qp-00dapS; Sun, 22 Jan 2017 19:13:34 +0100 Subject: [PATCH 3/9] KVM: Move error code settings in kvm_vcpu_compat_ioctl() To: kvm@vger.kernel.org, Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <0fa315b6-2fc7-3833-32eb-4e58671ac776@users.sourceforge.net> Date: Sun, 22 Jan 2017 19:13:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:1Ucjg/1V3MDcIqRQ//hXFgEpCRlRb/mmjlK82V2E4oZGKSYvMg/ sAbMwRYHIk2d85eZlXqYDhJfHzhMBxfQtU6efJnxVULwwSwCqO5vN42eHkLu/vwt6p09pNF uKgkTO1aPCXhf/lOXMMyYCIZjyt1iIKtpe5aUhQBHxVyNl89T1crms9DLbPMy5I5mcHdO5F 9bm5Mvjn62lRtcfKlZgHg== X-UI-Out-Filterresults: notjunk:1; V01:K0:eyeIHpqdFeE=:MO1UwksyGrZtqAaeyvg8+X KXhlsBWUxXQ8OpjhxvUWaAqH6fDtc7hKDzDVRXL8foUTRkYyBasOeFZRo+KTDoXjL5n7NvGLU s+tHGwz/kZVMANeavWIcAv9JBqmoDMAXHPmftQgTuLoZT86bS3E7ijlZxHW1wPECyndSSP31j FLVlrBYDZbvmqxKmf6ykGNmXgEU/9w71Mzmn2svT43Zq+EdJrxdZGcqYIxMBxVb9dyxZqtXQ+ qqQYk0FNqUnKYRSjPej7Ax57L07bkvZtL/6tBBila++J174QZiqZZRcQ93oxdTb+qCka4Z0ff dcvXep7Od/XAVD2y/Dbx98vtnVRwsS2k2Bv/5hnUQCIoQ1MO76XFP2hVvMmvDsFfn4KIHWZOs QehnvOkQbyxrPJ0mPDtSfpvVh1Izz8BSc93ZC/fW4fgjILyYB4lXSmtfJryYIWgQvkr4LE513 +bbrv07DZx68z+PbRQA3uNBhQdTHmhCiOu4jQEzFO17wUQw34luGKNxvzBm+Lq8+6LA9BrKtR eNE7dxNbhBscB0teh23tpXTwGib5+g4vsALxEzmOHQykzR5KNZyCxEkXA66OOx7uJaow7NHcp 9tPpVlCFMarOHhgDVvSnNoMJnBsQqktFk1GIXBlBBCOhcIIhTcgkHtN8agyCpkfkeaVD+1q05 qLS98kmF8JUpzOpBTpRAAP43RexGlwLA0+khkqVQnP8viRvNpHZTyAydGXXj1G/skXN/NhUZs wK6sG9lIyd8Nw+eLTxoujkGzNJYoUPudyVIVV5cDQhSd8XZFSdNTDrMOs9gWrY7T1QvRlGRjN 6PzGzNz Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 22 Jan 2017 13:57:40 +0100 * A local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding settings into if branches to indicate a software failure there. This issue was detected by using the Coccinelle software. * Return directly after a call of the function "copy_from_user" (or an other check) failed in a case block. * Delete the jump label "out" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- virt/kvm/kvm_main.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2773e5012948..62f24d8eaaa2 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2743,17 +2743,14 @@ static long kvm_vcpu_compat_ioctl(struct file *filp, sigset_t sigset; if (argp) { - r = -EFAULT; if (copy_from_user(&kvm_sigmask, argp, sizeof(kvm_sigmask))) - goto out; - r = -EINVAL; + return -EFAULT; if (kvm_sigmask.len != sizeof(csigset)) - goto out; - r = -EFAULT; + return -EINVAL; if (copy_from_user(&csigset, sigmask_arg->sigset, sizeof(csigset))) - goto out; + return -EFAULT; sigset_from_compat(&sigset, &csigset); r = kvm_vcpu_ioctl_set_sigmask(vcpu, &sigset); } else @@ -2763,8 +2760,6 @@ static long kvm_vcpu_compat_ioctl(struct file *filp, default: r = kvm_vcpu_ioctl(filp, ioctl, arg); } - -out: return r; } #endif