diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2022-07-18 14:10:45 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-08-02 17:22:48 -0600 |
commit | 80e2768496a494ce3166f8358d8665d2a056bcb7 (patch) | |
tree | 007354addcbc048cc00d3ded369e0fe3b513d8e1 /drivers | |
parent | 4daf7fa07ee3c31d5b03b87f96dbf3d8151ef654 (diff) | |
download | linux-80e2768496a494ce3166f8358d8665d2a056bcb7.tar.bz2 |
nvme-auth: uninitialized variable in nvme_auth_transform_key()
A couple of the early error gotos call kfree_sensitive(transformed_key);
before "transformed_key" has been initialized.
Fixes: db1312dd9548 ("nvmet: implement basic In-Band Authentication")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/nvme/common/auth.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c index 4b146cec9406..df20445918db 100644 --- a/drivers/nvme/common/auth.c +++ b/drivers/nvme/common/auth.c @@ -272,26 +272,33 @@ u8 *nvme_auth_transform_key(struct nvme_dhchap_key *key, char *nqn) shash->tfm = key_tfm; ret = crypto_shash_setkey(key_tfm, key->key, key->len); if (ret < 0) - goto out_free_shash; + goto out_free_transformed_key; ret = crypto_shash_init(shash); if (ret < 0) - goto out_free_shash; + goto out_free_transformed_key; ret = crypto_shash_update(shash, nqn, strlen(nqn)); if (ret < 0) - goto out_free_shash; + goto out_free_transformed_key; ret = crypto_shash_update(shash, "NVMe-over-Fabrics", 17); if (ret < 0) - goto out_free_shash; + goto out_free_transformed_key; ret = crypto_shash_final(shash, transformed_key); + if (ret < 0) + goto out_free_transformed_key; + + kfree(shash); + crypto_free_shash(key_tfm); + + return transformed_key; + +out_free_transformed_key: + kfree_sensitive(transformed_key); out_free_shash: kfree(shash); out_free_key: crypto_free_shash(key_tfm); - if (ret < 0) { - kfree_sensitive(transformed_key); - return ERR_PTR(ret); - } - return transformed_key; + + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(nvme_auth_transform_key); |