From: Markus Elfring <Markus.Elfring@web.de>
To: virtualization@lists.linux.dev, linux-crypto@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
"Eugenio Pérez" <eperezma@redhat.com>,
Gonglei <arei.gonglei@huawei.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Jason Wang" <jasowang@redhat.com>,
"lei he" <helei.sig11@bytedance.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"zhenwei pi" <pizhenwei@bytedance.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] crypto: virtio/akcipher - Move a pointer assignment in virtio_crypto_rsa_set_key()
Date: Sat, 12 Oct 2024 10:06:37 +0200 [thread overview]
Message-ID: <80b91321-138c-41de-95c7-47c3be07fe76@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Oct 2024 09:51:58 +0200
Move the reset of the data structure member “n” to a null pointer
into an if branch so that this assignment will be performed only after
a key parsing failure.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
index 48fee07b7e51..56557d4778b0 100644
--- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
+++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
@@ -355,7 +355,6 @@ static int virtio_crypto_rsa_set_key(struct crypto_akcipher *tfm,
/* mpi_free will test n, just free it. */
mpi_free(rsa_ctx->n);
- rsa_ctx->n = NULL;
if (private) {
keytype = VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE;
@@ -365,8 +364,10 @@ static int virtio_crypto_rsa_set_key(struct crypto_akcipher *tfm,
ret = rsa_parse_pub_key(&rsa_key, key, keylen);
}
- if (ret)
+ if (ret) {
+ rsa_ctx->n = NULL;
return ret;
+ }
rsa_ctx->n = mpi_read_raw_data(rsa_key.n, rsa_key.n_sz);
if (!rsa_ctx->n)
--
2.46.1
next reply other threads:[~2024-10-12 8:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-12 8:06 Markus Elfring [this message]
2024-10-12 8:24 ` zhenwei pi
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=80b91321-138c-41de-95c7-47c3be07fe76@web.de \
--to=markus.elfring@web.de \
--cc=arei.gonglei@huawei.com \
--cc=davem@davemloft.net \
--cc=eperezma@redhat.com \
--cc=helei.sig11@bytedance.com \
--cc=herbert@gondor.apana.org.au \
--cc=jasowang@redhat.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=nathan@kernel.org \
--cc=pizhenwei@bytedance.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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
all inboxes | Powered by JetHome®