Skip to contentSkip to conversation

crypto: ccp: initialize error

PATCH In review Tom Rix 2 participants 2 messages Jan 10, 2023

Subsystems (3)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH v2 1/1 crypto: ccp: initialize error

clang static analysis reports this problem drivers/crypto/ccp/sev-dev.c:1347:3: warning: 3rd function call
argument is an uninitialized value [core.CallAndMessage]

    dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

__sev_platform_init_locked() can return without setting the error parameter, causing the dev_err() to report a garbage value.

Fixes 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")

---
v2 : cleanup commit log
---
drivers/crypto/ccp/sev-dev.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/sev-dev.c +1 -1
index 56998bc579d6..643cccc06a0b 100644
@@ -1307,7 +1307,7 @@ EXPORT_SYMBOL_GPL(sev_issue_cmd_external_user);
 void sev_pci_init(void)
 {
 	struct sev_device *sev = psp_master->sev_data;
-	int error, rc;
+	int error = 0, rc;
 
 	if (!sev)
 		return;
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 1 line · Tom Rix

clang static analysis reports this problem

s/clang/Clang/

Quoted 11 lines

drivers/crypto/ccp/sev-dev.c:1347:3: warning: 3rd function call
argument is an uninitialized value [core.CallAndMessage]

     dev_err(sev->dev, "SEV: failed to INIT error %#x, rc %d\n",
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

__sev_platform_init_locked() can return without setting the error parameter, causing the dev_err() to report a garbage value.

Fixes 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")

The subject is pretty generic and confusing. A better subject would be:

crypto: ccp: Fix use of uninitialized variable

or something along that line.

Thanks,
Tom

Quoted 19 lines

---
v2 : cleanup commit log
---
drivers/crypto/ccp/sev-dev.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/sev-dev.c +1 -1
index 56998bc579d6..643cccc06a0b 100644
@@ -1307,7 +1307,7 @@ EXPORT_SYMBOL_GPL(sev_issue_cmd_external_user);
  void sev_pci_init(void)
  {
  	struct sev_device *sev = psp_master->sev_data;
-	int error, rc;
+	int error = 0, rc;
 
  	if (!sev)
  		return;