linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Haiwei Li <lihaiwei.kernel@gmail.com>
To: linux-crypto@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: thomas.lendacky@amd.com, gary.hook@amd.com,
	herbert@gondor.apana.org.au, davem@davemloft.net
Subject: [PATCH] CRYPTO: Fix initialize 'psp_ret' to avoid uninitialized usage in error paths
Date: Thu, 28 Nov 2019 08:41:32 +0800	[thread overview]
Message-ID: <aa2fd7ae-261a-5c62-821c-96479d11309b@gmail.com> (raw)

 From 842cac9822aafd3cfe2da154b92b033fa1ed0d2d Mon Sep 17 00:00:00 2001
From: Haiwei Li <lihaiwei@tencent.com>
Date: Thu, 28 Nov 2019 08:25:16 +0800
Subject: [PATCH] fix: initialize @psp_ret to avoid uninitialized usage 
in error paths

Initialize @psp_ret to -1 to avoid uninitialized usage in error paths.
Such as the function 'sev_flush_asides' in file 'arch/x86/kvm/svm.c'.


Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
  drivers/crypto/ccp/psp-dev.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index 39fdd06..3501562 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -155,6 +155,9 @@ static int __sev_do_cmd_locked(int cmd, void *data, 
int *psp_ret)
  	unsigned int phys_lsb, phys_msb;
  	unsigned int reg, ret = 0;

+	if (psp_ret)
+		*psp_ret = -1;
+
  	if (!psp)
  		return -ENODEV;

--
1.8.3.1

             reply	other threads:[~2019-11-28  0:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28  0:41 Haiwei Li [this message]
2019-12-02 16:16 ` [PATCH] CRYPTO: Fix initialize 'psp_ret' to avoid uninitialized usage in error paths Gary R Hook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa2fd7ae-261a-5c62-821c-96479d11309b@gmail.com \
    --to=lihaiwei.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=gary.hook@amd.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).