public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm:svm: Return the correct error code
@ 2020-11-26  7:13 彭浩(Richard)
  2020-11-30 19:58 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: 彭浩(Richard) @ 2020-11-26  7:13 UTC (permalink / raw)
  To: Paolo Bonzini, Suravee.Suthikulpanit@amd.com
  Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org

The return value of sev_asid_new is assigned to the variable asid, which
should be returned directly if the asid is an error code.

Fixes: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
Signed-off-by: Peng Hao <richard.peng@oppo.com>
---
 arch/x86/kvm/svm/sev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 566f4d18185b..41cea6b69860 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -174,7 +174,7 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)

        asid = sev_asid_new();
        if (asid < 0)
-               return ret;
+               return asid;

        ret = sev_platform_init(&argp->error);
        if (ret)
--
2.18.4

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

* Re: [PATCH] kvm:svm: Return the correct error code
  2020-11-26  7:13 [PATCH] kvm:svm: Return the correct error code 彭浩(Richard)
@ 2020-11-30 19:58 ` Sean Christopherson
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2020-11-30 19:58 UTC (permalink / raw)
  To: 彭浩(Richard)
  Cc: Paolo Bonzini, Suravee.Suthikulpanit@amd.com,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org

On Thu, Nov 26, 2020, 彭浩(Richard) wrote:
> The return value of sev_asid_new is assigned to the variable asid, which
> should be returned directly if the asid is an error code.
> 
> Fixes: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
> Signed-off-by: Peng Hao <richard.peng@oppo.com>

It's probably worth noting in the changelog that this is a nop.  sev_asid_new()
can only fail with -EBUSY, and ret is guaranteed to be -EBUSY as well.  I agree
it's probably better to return the result of sev_asid_new() instead of assuuming
it will always return -EBUSY.

> ---
>  arch/x86/kvm/svm/sev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 566f4d18185b..41cea6b69860 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -174,7 +174,7 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
> 
>         asid = sev_asid_new();
>         if (asid < 0)
> -               return ret;
> +               return asid;
> 
>         ret = sev_platform_init(&argp->error);
>         if (ret)
> --
> 2.18.4

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

end of thread, other threads:[~2020-11-30 19:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-26  7:13 [PATCH] kvm:svm: Return the correct error code 彭浩(Richard)
2020-11-30 19:58 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox