* [PATCH v2] KVM: SVM: Fix "error" isn't initialized
@ 2019-11-27 7:23 Haiwei Li
2019-11-27 9:16 ` Christophe de Dinechin
2019-11-27 18:11 ` Tom Lendacky
0 siblings, 2 replies; 4+ messages in thread
From: Haiwei Li @ 2019-11-27 7:23 UTC (permalink / raw)
To: x86, kvm, linux-kernel, linux-crypto
Cc: pbonzini, rkrcmar, Sean Christopherson, vkuznets, wanpengli,
jmattson, joro, tglx, mingo, bp, hpa, thomas.lendacky, gary.hook,
herbert, davem
From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
From: Haiwei Li <lihaiwei@tencent.com>
Date: Wed, 27 Nov 2019 15:00:49 +0800
Subject: [PATCH v2] fix: 'error' is not initialized
There are a bunch of error paths were "error" isn't initialized.
Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
arch/x86/kvm/svm.c | 3 ++-
drivers/crypto/ccp/psp-dev.c | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 362e874..9eef6fc 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6308,7 +6308,8 @@ static int sev_flush_asids(void)
up_write(&sev_deactivate_lock);
if (ret)
- pr_err("SEV: DF_FLUSH failed, ret=%d, error=%#x\n", ret, error);
+ pr_err("SEV: DF_FLUSH failed, ret=%d. PSP returned error=%#x\n",
+ ret, error);
return ret;
}
diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index 39fdd06..c486c24 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -155,6 +155,8 @@ static int __sev_do_cmd_locked(int cmd, void *data,
int *psp_ret)
unsigned int phys_lsb, phys_msb;
unsigned int reg, ret = 0;
+ *psp_ret = -1;
+
if (!psp)
return -ENODEV;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: SVM: Fix "error" isn't initialized
2019-11-27 7:23 [PATCH v2] KVM: SVM: Fix "error" isn't initialized Haiwei Li
@ 2019-11-27 9:16 ` Christophe de Dinechin
2019-11-27 18:11 ` Tom Lendacky
1 sibling, 0 replies; 4+ messages in thread
From: Christophe de Dinechin @ 2019-11-27 9:16 UTC (permalink / raw)
To: Haiwei Li
Cc: x86, KVM list, linux-kernel, linux-crypto, pbonzini, rkrcmar,
Sean Christopherson, vkuznets, wanpengli, jmattson, joro, tglx,
mingo, bp, hpa, thomas.lendacky, gary.hook, herbert, davem
> On 27 Nov 2019, at 08:23, Haiwei Li <lihaiwei.kernel@gmail.com> wrote:
>
> From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@tencent.com>
> Date: Wed, 27 Nov 2019 15:00:49 +0800
> Subject: [PATCH v2] fix: 'error' is not initialized
>
> There are a bunch of error paths were "error" isn't initialized.
>
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> arch/x86/kvm/svm.c | 3 ++-
> drivers/crypto/ccp/psp-dev.c | 2 ++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 362e874..9eef6fc 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -6308,7 +6308,8 @@ static int sev_flush_asids(void)
> up_write(&sev_deactivate_lock);
>
> if (ret)
> - pr_err("SEV: DF_FLUSH failed, ret=%d, error=%#x\n", ret, error);
> + pr_err("SEV: DF_FLUSH failed, ret=%d. PSP returned error=%#x\n",
> + ret, error);
This specific text change does not seem to match the patch description.
>
> return ret;
> }
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index 39fdd06..c486c24 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -155,6 +155,8 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
> unsigned int phys_lsb, phys_msb;
> unsigned int reg, ret = 0;
>
> + *psp_ret = -1;
> +
> if (!psp)
> return -ENODEV;
>
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: SVM: Fix "error" isn't initialized
2019-11-27 7:23 [PATCH v2] KVM: SVM: Fix "error" isn't initialized Haiwei Li
2019-11-27 9:16 ` Christophe de Dinechin
@ 2019-11-27 18:11 ` Tom Lendacky
1 sibling, 0 replies; 4+ messages in thread
From: Tom Lendacky @ 2019-11-27 18:11 UTC (permalink / raw)
To: Haiwei Li, x86, kvm, linux-kernel, linux-crypto
Cc: pbonzini, rkrcmar, Sean Christopherson, vkuznets, wanpengli,
jmattson, joro, tglx, mingo, bp, hpa, gary.hook, herbert, davem
On 11/27/19 1:23 AM, Haiwei Li wrote:
> From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@tencent.com>
> Date: Wed, 27 Nov 2019 15:00:49 +0800
> Subject: [PATCH v2] fix: 'error' is not initialized
>
> There are a bunch of error paths were "error" isn't initialized.
Please provide a better patch commit message and just fix the actual
problem, which is error is uninitialized in sev_flush_asids(). Please
just initialize error to zero.
Thanks,
Tom
>
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> arch/x86/kvm/svm.c | 3 ++-
> drivers/crypto/ccp/psp-dev.c | 2 ++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 362e874..9eef6fc 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -6308,7 +6308,8 @@ static int sev_flush_asids(void)
> up_write(&sev_deactivate_lock);
>
> if (ret)
> - pr_err("SEV: DF_FLUSH failed, ret=%d, error=%#x\n", ret, error);
> + pr_err("SEV: DF_FLUSH failed, ret=%d. PSP returned error=%#x\n",
> + ret, error);
>
> return ret;
> }
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index 39fdd06..c486c24 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -155,6 +155,8 @@ static int __sev_do_cmd_locked(int cmd, void *data,
> int *psp_ret)
> unsigned int phys_lsb, phys_msb;
> unsigned int reg, ret = 0;
>
> + *psp_ret = -1;
> +
> if (!psp)
> return -ENODEV;
>
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: SVM: Fix "error" isn't initialized
@ 2019-11-27 8:47 linmiaohe
0 siblings, 0 replies; 4+ messages in thread
From: linmiaohe @ 2019-11-27 8:47 UTC (permalink / raw)
To: Haiwei Li, x86, kvm, linux-kernel, linux-crypto
Cc: pbonzini, rkrcmar, Sean Christopherson, vkuznets, wanpengli,
jmattson, joro, tglx, mingo, bp, hpa, thomas.lendacky, gary.hook,
herbert, davem
> From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@tencent.com>
> Date: Wed, 27 Nov 2019 15:00:49 +0800
> Subject: [PATCH v2] fix: 'error' is not initialized
>
> There are a bunch of error paths were "error" isn't initialized.
> @@ -155,6 +155,8 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
> unsigned int phys_lsb, phys_msb;
> unsigned int reg, ret = 0;
>
> + *psp_ret = -1;
> +
> if (!psp)
> return -ENODEV;
>
The arg psp_ret may be NULL in some path such as sev_guest_df_flush(NULL).
So you have to check it against NULL.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-27 18:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 7:23 [PATCH v2] KVM: SVM: Fix "error" isn't initialized Haiwei Li
2019-11-27 9:16 ` Christophe de Dinechin
2019-11-27 18:11 ` Tom Lendacky
2019-11-27 8:47 linmiaohe
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).