crypto: ccp: Fix dereferencing uninitialized error pointer
Subsystems (3)
Ashish Kalra
maintainerPATCH 1/1 crypto: ccp: Fix dereferencing uninitialized error pointer
From: Ashish Kalra <[email protected]>
Fix below smatch warnings:drivers/crypto/ccp/sev-dev.c:1312 __sev_platform_init_locked()
error: we previously assumed 'error' could be null
--- drivers/crypto/ccp/sev-dev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/crypto/ccp/sev-dev.c +5 -3
@@ -1276,9 +1276,11 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev)static int __sev_platform_init_locked (int *error) { -int rc, psp_ret =SEV_RET_NO_FW_CALL ; +int rc, psp_ret, dfflush_error;struct sev_device *sev; + psp_ret = dfflush_error =SEV_RET_NO_FW_CALL ; +if (!psp_master || !psp_master->sev_data)return -ENODEV ;
@@ -1320,10 +1322,10 @@ static int __sev_platform_init_locked(int *error)/* Prepare for first SEV guest launch after INIT */ wbinvd_on_all_cpus (); - rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , error); + rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , &dfflush_error);if (rc) {dev_err (sev->dev,"SEV: DF_FLUSH failed %#x, rc %d\n" , - *error, rc); + dfflush_error, rc);return rc; }
Signature · 1 line
2.34.1
Herbert Xu
maintainerdrivers/crypto/ccp/sev-dev.c static int __sev_platform_init_locked(int *error) · line 1328
Quoted 11 lines · Ashish Kalra
drivers/crypto/ccp/sev-dev.c +2
-2@@ -1320,10 +1322,10 @@ static int __sev_platform_init_locked(int *error)/* Prepare for first SEV guest launch after INIT */ wbinvd_on_all_cpus (); - rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , error); + rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , &dfflush_error);if (rc) {dev_err (sev->dev,"SEV: DF_FLUSH failed %#x, rc %d\n" , - *error, rc); + dfflush_error, rc);
dfflush_error is never returned to the caller unlike psp_ret, is this intentional?
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
Kalra, Ashish
maintainerQuoted 4 lines · Herbert Xu
Quoted 3 lines · Ashish Kalra
(quoted diff) +0
-0@@ -1320,10 +1322,10 @@ static int __sev_platform_init_locked(int *error)
Quoted 11 lines
drivers/crypto/ccp/sev-dev.c static int __sev_platform_init_locked(int *error) · line 1328
Quoted 8 lines
drivers/crypto/ccp/sev-dev.c +2
-2/* Prepare for first SEV guest launch after INIT */ wbinvd_on_all_cpus (); - rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , error); + rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , &dfflush_error);if (rc) {dev_err (sev->dev,"SEV: DF_FLUSH failed %#x, rc %d\n" , - *error, rc); + dfflush_error, rc);
dfflush_erroris never returned to the caller unlikepsp_ret, is this intentional?
Yes, this is intentional.
As this function does SEV_INIT, it needs to return the firmware error (psp_ret) of SEV_INIT back to the caller.
For DF_FLUSH failures, errors are indicated only via the log and for that dfflush_error is used.
Thanks,
Ashish
Quoted 2 lines
Thanks,
Quoted 10 lines · Ashish Kalra
From: Ashish Kalra <[email protected]>
Fix below smatch warnings:
drivers/crypto/ccp/sev-dev.c:1312__sev_platform_init_locked()
error: we previously assumed 'error' could be nullFixes 9770b428b1a2 ("crypto: ccp - Move dev_info/err messages for SEV/SNP init and shutdown")Reported-by Dan Carpenter <[email protected]>Signed-off-by Ashish Kalra <[email protected]>
Quoted 34 lines
--- drivers/crypto/ccp/sev-dev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/crypto/ccp/sev-dev.c +5
-3@@ -1276,9 +1276,11 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev)static int __sev_platform_init_locked (int *error) { -int rc, psp_ret =SEV_RET_NO_FW_CALL ; +int rc, psp_ret, dfflush_error;struct sev_device *sev; + psp_ret = dfflush_error =SEV_RET_NO_FW_CALL ; +if (!psp_master || !psp_master->sev_data)return -ENODEV ;@@ -1320,10 +1322,10 @@ static int __sev_platform_init_locked(int *error)/* Prepare for first SEV guest launch after INIT */ wbinvd_on_all_cpus (); - rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , error); + rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , &dfflush_error);if (rc) {dev_err (sev->dev,"SEV: DF_FLUSH failed %#x, rc %d\n" , - *error, rc); + dfflush_error, rc);return rc; }
Herbert Xu
maintainerQuoted 6 lines · Ashish Kalra
From: Ashish Kalra <[email protected]>
Fix below smatch warnings:
drivers/crypto/ccp/sev-dev.c:1312__sev_platform_init_locked()
error: we previously assumed 'error' could be null
Quoted 7 lines
Fixes 9770b428b1a2 ("crypto: ccp - Move dev_info/err messages for SEV/SNP init and shutdown")Reported-by Dan Carpenter <[email protected]>Signed-off-by Ashish Kalra <[email protected]>--- drivers/crypto/ccp/sev-dev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Patch applied. 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