crypto: tegra: Fix Coverity defects

Fix resource leak and dead code which causes coverity defects.

ID 10162255
ID 10162275
ID 10162278
ID 10162282
ID 10162263
ID 10162268

Bug 3952896

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Change-Id: Ib09dde2b65a3fc74bd30a4fb0e1bd594caf826ec
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2850397
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Akhil R
2023-01-27 13:13:01 +05:30
committed by mobile promotions
parent 17a785e632
commit 8a61c9f119

View File

@@ -4,7 +4,7 @@
*
* Support for Tegra Security Engine hardware crypto algorithms.
*
* Copyright (c) 2015-2022, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2015-2023, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -1457,10 +1457,8 @@ static int tegra_se_channel_submit_gather(struct tegra_se_dev *se_dev,
job->syncpt, job->syncpt_end,
(u32)MAX_SCHEDULE_TIMEOUT, NULL);
if (se_dev->cmdbuf_addr_list) {
atomic_set(&se_dev->cmdbuf_addr_list[
se_dev->cmdbuf_list_entry].free, 1);
}
atomic_set(&se_dev->cmdbuf_addr_list[
se_dev->cmdbuf_list_entry].free, 1);
}
se_dev->req_cnt = 0;
@@ -4406,6 +4404,7 @@ static int tegra_se_send_rsa_data(struct tegra_se_dev *se_dev,
dma_free_attrs(se_dev->dev->parent, SZ_4K, cmdbuf->gather->cmdbuf_addr,
cmdbuf->gather->iova, 0);
kfree(cmdbuf);
return err;
}
@@ -4537,8 +4536,10 @@ static int tegra_se_rsa_setkey(struct crypto_akcipher *tfm, const void *key,
mutex_unlock(&se_dev->mtx);
if (err)
tegra_se_rsa_free_key_slot(ctx->slot);
dma_free_attrs(se_dev->dev->parent, SZ_64K, cmdbuf->gather->cmdbuf_addr,
cmdbuf->gather->iova, 0);
kfree(cmdbuf);
return err;
}
@@ -4812,6 +4813,7 @@ static int tegra_se_dh_setkey(struct crypto_kpp *tfm)
}
dma_free_attrs(se_dev->dev->parent, SZ_64K, cmdbuf->gather->cmdbuf_addr,
cmdbuf->gather->iova, 0);
kfree(cmdbuf);
return err;
}
@@ -7050,19 +7052,8 @@ static struct akcipher_alg rsa_alg = {
static int tegra_se_nvhost_prepare_poweroff(struct platform_device *pdev)
{
struct nvhost_device_data *pdata = platform_get_drvdata(pdev);
struct tegra_se_dev *se_dev = pdata->private_data;
return 0;
if (se_dev->channel) {
// host1x_syncpt_put(se_dev->syncpt);
host1x_channel_put(se_dev->channel);
se_dev->channel = NULL;
/* syncpt will be released along with channel */
se_dev->syncpt_id = 0;
}
/* Runtime PM not supported by Host1x */
return 0;
}
@@ -7404,10 +7395,7 @@ static int tegra_se_clk_init(struct platform_device *pdev)
static int tegra_se_client_init(struct host1x_client *client)
{
struct tegra_se_dev *se_dev = container_of(client, struct tegra_se_dev, client);
return 0;
return tegra_se_crypto_register(se_dev);
}
static const struct host1x_client_ops tegra_se_client_ops = {