crypto: ccp: initialize 'error' variable to zero
Subsystems (3)
PATCH v3 1/1 crypto: ccp: initialize 'error' variable to zero
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.
---
v2 cleanup commit log
v3 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
@@ -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
Quoted 7 lines · Tom Rix
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", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
__sev_platform_init_locked()can return without setting the error parameter, causing thedev_err()to report a garbage value.Fixes 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")Signed-off-by Tom Rix <[email protected]>
Thanks for the patch!
Quoted 24 lines
---
v2 cleanup commit log
v3 cleanup commit log--- drivers/crypto/ccp/sev-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/crypto/ccp/sev-dev.c +1
-2@@ -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 ; --2.27.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 6 lines · Tom Rix
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", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
__sev_platform_init_locked()can return without setting the error parameter, causing thedev_err()to report a garbage value.Fixes 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")Signed-off-by Tom Rix <[email protected]>
Quoted 20 lines
---
v2 cleanup commit log
v3 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@@ -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 ;
Herbert Xu
maintainerQuoted 10 lines · Tom Rix
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 thedev_err()to report a garbage value.
Quoted 8 lines
Fixes 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")Signed-off-by Tom Rix <[email protected]>---
v2 cleanup commit log
v3 cleanup commit log--- drivers/crypto/ccp/sev-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
I think error should be removed completely on top of
https://patchwork.kernel.org/project/linux-crypto/patch/[email protected]/
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt