Skip to contentSkip to conversation

KVM: SVM: Fix "error" isn't initialized

PATCH In review Haiwei Li 3 participants 3 messages Nov 27, 2019

Subsystems (5)
x86 KVM Crypto API KVM x86 +1 more subsystems
lore
Share & tools
lore

Haiwei Li

author
#0 lore raw

PATCH v2 1/1 KVM: SVM: Fix "error" isn't initialized

From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
From: Haiwei Li <[email protected]>
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.

---
 arch/x86/kvm/svm.c           | 3 ++-
 drivers/crypto/ccp/psp-dev.c | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/kvm/svm.c +2 -1
index 362e874..9eef6fc 100644
@@ -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;
 }
drivers/crypto/ccp/psp-dev.c +2 -0
index 39fdd06..c486c24 100644
@@ -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

#1 lore raw
Quoted 23 lines · Haiwei Li

From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
From: Haiwei Li <[email protected]>
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.

---
arch/x86/kvm/svm.c | 3 ++-
drivers/crypto/ccp/psp-dev.c | 2 ++

2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/kvm/svm.c +0 -0
index 362e874..9eef6fc 100644

arch/x86/kvm/svm.c static int sev_flush_asids(void) · line 6312

Quoted 6 lines
arch/x86/kvm/svm.c +2 -1
@@ -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.

Quoted 18 lines
arch/x86/kvm/svm.c +0 -0
 	return ret;
 }
drivers/crypto/ccp/psp-dev.c +2 -1
index 39fdd06..c486c24 100644
@@ -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

maintainer
#2 lore raw
In reply to Haiwei Li
Quoted 6 lines · Haiwei Li

From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
From: Haiwei Li <[email protected]>
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

Quoted 38 lines
---
  arch/x86/kvm/svm.c           | 3 ++-
  drivers/crypto/ccp/psp-dev.c | 2 ++
  2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/kvm/svm.c +2 -1
index 362e874..9eef6fc 100644
@@ -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;
  }
drivers/crypto/ccp/psp-dev.c +2 -0
index 39fdd06..c486c24 100644
@@ -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;
Signature · 2 lines
-- 
1.8.3.1