All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] crypto: ccp: initialize 'error' variable to zero
@ 2023-01-10 17:08 Tom Rix
  2023-01-17 18:17 ` Nick Desaulniers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Rix @ 2023-01-10 17:08 UTC (permalink / raw)
  To: brijesh.singh, thomas.lendacky, john.allen, herbert, davem,
	nathan, ndesaulniers
  Cc: linux-crypto, linux-kernel, llvm, 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 the dev_err() to report a garbage
value.

Fixes: 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support")
Signed-off-by: Tom Rix <trix@redhat.com>
---
v2 cleanup commit log
v3 cleanup commit log
---
 drivers/crypto/ccp/sev-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 56998bc579d6..643cccc06a0b 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] crypto: ccp: initialize 'error' variable to zero
  2023-01-10 17:08 [PATCH v3] crypto: ccp: initialize 'error' variable to zero Tom Rix
@ 2023-01-17 18:17 ` Nick Desaulniers
  2023-01-17 18:44 ` Tom Lendacky
  2023-01-20 10:08 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2023-01-17 18:17 UTC (permalink / raw)
  To: Tom Rix
  Cc: brijesh.singh, thomas.lendacky, john.allen, herbert, davem,
	nathan, linux-crypto, linux-kernel, llvm

On Tue, Jan 10, 2023 at 9:09 AM Tom Rix <trix@redhat.com> wrote:
>
> 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")
> Signed-off-by: Tom Rix <trix@redhat.com>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
> v2 cleanup commit log
> v3 cleanup commit log
> ---
>  drivers/crypto/ccp/sev-dev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 56998bc579d6..643cccc06a0b 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -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
>
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] crypto: ccp: initialize 'error' variable to zero
  2023-01-10 17:08 [PATCH v3] crypto: ccp: initialize 'error' variable to zero Tom Rix
  2023-01-17 18:17 ` Nick Desaulniers
@ 2023-01-17 18:44 ` Tom Lendacky
  2023-01-20 10:08 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Lendacky @ 2023-01-17 18:44 UTC (permalink / raw)
  To: Tom Rix, brijesh.singh, john.allen, herbert, davem, nathan, ndesaulniers
  Cc: linux-crypto, linux-kernel, llvm

On 1/10/23 11:08, Tom Rix wrote:
> 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")
> Signed-off-by: Tom Rix <trix@redhat.com>

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
> v2 cleanup commit log
> v3 cleanup commit log
> ---
>   drivers/crypto/ccp/sev-dev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 56998bc579d6..643cccc06a0b 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -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;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] crypto: ccp: initialize 'error' variable to zero
  2023-01-10 17:08 [PATCH v3] crypto: ccp: initialize 'error' variable to zero Tom Rix
  2023-01-17 18:17 ` Nick Desaulniers
  2023-01-17 18:44 ` Tom Lendacky
@ 2023-01-20 10:08 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2023-01-20 10:08 UTC (permalink / raw)
  To: Tom Rix
  Cc: brijesh.singh, thomas.lendacky, john.allen, davem, nathan,
	ndesaulniers, linux-crypto, linux-kernel, llvm

On Tue, Jan 10, 2023 at 12:08:48PM -0500, Tom Rix wrote:
> 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")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> 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/20230110191201.29666-1-jarkko@profian.com/

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-20 10:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 17:08 [PATCH v3] crypto: ccp: initialize 'error' variable to zero Tom Rix
2023-01-17 18:17 ` Nick Desaulniers
2023-01-17 18:44 ` Tom Lendacky
2023-01-20 10:08 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.