Skip to content
This repository has been archived by the owner on Nov 7, 2021. It is now read-only.

Commit

Permalink
crypto: msm: update QTI crypto drivers for msm-4.14
Browse files Browse the repository at this point in the history
Fix compilation issues for QTI crypto driver on msm-4.14 ,
this change does code clean up to remove unsupported SMMU
attribute, allocate qcedev_async_req from heap instead of
stack, and add NULL pointer check for ota_async_req.

Change-Id: I5cabcb6993d8855275f3b38c7de6eafb77f8cbf4
Signed-off-by: Zhen Kong <[email protected]>
Signed-off-by: Naitik Bharadiya <[email protected]>
  • Loading branch information
Zhen Kong authored and Naitik Bharadiya committed Nov 15, 2019
1 parent aeb74a7 commit 534ad92
Showing 1 changed file with 42 additions and 38 deletions.
80 changes: 42 additions & 38 deletions drivers/crypto/msm/qcedev.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* QTI CE device driver.
*
* Copyright (c) 2010-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -1668,12 +1668,16 @@ static inline long qcedev_ioctl(struct file *file,
int err = 0;
struct qcedev_handle *handle;
struct qcedev_control *podev;
struct qcedev_async_req qcedev_areq;
struct qcedev_async_req *qcedev_areq;
struct qcedev_stat *pstat;

qcedev_areq = kzalloc(sizeof(struct qcedev_async_req), GFP_KERNEL);
if (!qcedev_areq)
return -ENOMEM;

handle = file->private_data;
podev = handle->cntl;
qcedev_areq.handle = handle;
qcedev_areq->handle = handle;
if (podev == NULL || podev->magic != QCEDEV_MAGIC) {
pr_err("%s: invalid handle %pK\n",
__func__, podev);
Expand All @@ -1684,27 +1688,27 @@ static inline long qcedev_ioctl(struct file *file,
if (_IOC_TYPE(cmd) != QCEDEV_IOC_MAGIC)
return -ENOTTY;

init_completion(&qcedev_areq.complete);
init_completion(&qcedev_areq->complete);
pstat = &_qcedev_stat;

switch (cmd) {
case QCEDEV_IOCTL_ENC_REQ:
case QCEDEV_IOCTL_DEC_REQ:
if (copy_from_user(&qcedev_areq.cipher_op_req,
if (copy_from_user(&qcedev_areq->cipher_op_req,
(void __user *)arg,
sizeof(struct qcedev_cipher_op_req)))
return -EFAULT;
qcedev_areq.op_type = QCEDEV_CRYPTO_OPER_CIPHER;
qcedev_areq->op_type = QCEDEV_CRYPTO_OPER_CIPHER;

if (qcedev_check_cipher_params(&qcedev_areq.cipher_op_req,
if (qcedev_check_cipher_params(&qcedev_areq->cipher_op_req,
podev))
return -EINVAL;

err = qcedev_vbuf_ablk_cipher(&qcedev_areq, handle);
err = qcedev_vbuf_ablk_cipher(qcedev_areq, handle);
if (err)
return err;
if (copy_to_user((void __user *)arg,
&qcedev_areq.cipher_op_req,
&qcedev_areq->cipher_op_req,
sizeof(struct qcedev_cipher_op_req)))
return -EFAULT;
break;
Expand All @@ -1713,23 +1717,23 @@ static inline long qcedev_ioctl(struct file *file,
{
struct scatterlist sg_src;

if (copy_from_user(&qcedev_areq.sha_op_req,
if (copy_from_user(&qcedev_areq->sha_op_req,
(void __user *)arg,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
mutex_lock(&hash_access_lock);
if (qcedev_check_sha_params(&qcedev_areq.sha_op_req, podev)) {
if (qcedev_check_sha_params(&qcedev_areq->sha_op_req, podev)) {
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
qcedev_areq.op_type = QCEDEV_CRYPTO_OPER_SHA;
err = qcedev_hash_init(&qcedev_areq, handle, &sg_src);
qcedev_areq->op_type = QCEDEV_CRYPTO_OPER_SHA;
err = qcedev_hash_init(qcedev_areq, handle, &sg_src);
if (err) {
mutex_unlock(&hash_access_lock);
return err;
}
mutex_unlock(&hash_access_lock);
if (copy_to_user((void __user *)arg, &qcedev_areq.sha_op_req,
if (copy_to_user((void __user *)arg, &qcedev_areq->sha_op_req,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
}
Expand All @@ -1742,19 +1746,19 @@ static inline long qcedev_ioctl(struct file *file,
{
struct scatterlist sg_src;

if (copy_from_user(&qcedev_areq.sha_op_req,
if (copy_from_user(&qcedev_areq->sha_op_req,
(void __user *)arg,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
mutex_lock(&hash_access_lock);
if (qcedev_check_sha_params(&qcedev_areq.sha_op_req, podev)) {
if (qcedev_check_sha_params(&qcedev_areq->sha_op_req, podev)) {
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
qcedev_areq.op_type = QCEDEV_CRYPTO_OPER_SHA;
qcedev_areq->op_type = QCEDEV_CRYPTO_OPER_SHA;

if (qcedev_areq.sha_op_req.alg == QCEDEV_ALG_AES_CMAC) {
err = qcedev_hash_cmac(&qcedev_areq, handle, &sg_src);
if (qcedev_areq->sha_op_req.alg == QCEDEV_ALG_AES_CMAC) {
err = qcedev_hash_cmac(qcedev_areq, handle, &sg_src);
if (err) {
mutex_unlock(&hash_access_lock);
return err;
Expand All @@ -1765,7 +1769,7 @@ static inline long qcedev_ioctl(struct file *file,
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
err = qcedev_hash_update(&qcedev_areq, handle, &sg_src);
err = qcedev_hash_update(qcedev_areq, handle, &sg_src);
if (err) {
mutex_unlock(&hash_access_lock);
return err;
Expand All @@ -1778,11 +1782,11 @@ static inline long qcedev_ioctl(struct file *file,
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
memcpy(&qcedev_areq.sha_op_req.digest[0],
memcpy(&qcedev_areq->sha_op_req.digest[0],
&handle->sha_ctxt.digest[0],
handle->sha_ctxt.diglen);
mutex_unlock(&hash_access_lock);
if (copy_to_user((void __user *)arg, &qcedev_areq.sha_op_req,
if (copy_to_user((void __user *)arg, &qcedev_areq->sha_op_req,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
}
Expand All @@ -1794,17 +1798,17 @@ static inline long qcedev_ioctl(struct file *file,
pr_err("%s Init was not called\n", __func__);
return -EINVAL;
}
if (copy_from_user(&qcedev_areq.sha_op_req,
if (copy_from_user(&qcedev_areq->sha_op_req,
(void __user *)arg,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
mutex_lock(&hash_access_lock);
if (qcedev_check_sha_params(&qcedev_areq.sha_op_req, podev)) {
if (qcedev_check_sha_params(&qcedev_areq->sha_op_req, podev)) {
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
qcedev_areq.op_type = QCEDEV_CRYPTO_OPER_SHA;
err = qcedev_hash_final(&qcedev_areq, handle);
qcedev_areq->op_type = QCEDEV_CRYPTO_OPER_SHA;
err = qcedev_hash_final(qcedev_areq, handle);
if (err) {
mutex_unlock(&hash_access_lock);
return err;
Expand All @@ -1815,12 +1819,12 @@ static inline long qcedev_ioctl(struct file *file,
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
qcedev_areq.sha_op_req.diglen = handle->sha_ctxt.diglen;
memcpy(&qcedev_areq.sha_op_req.digest[0],
qcedev_areq->sha_op_req.diglen = handle->sha_ctxt.diglen;
memcpy(&qcedev_areq->sha_op_req.digest[0],
&handle->sha_ctxt.digest[0],
handle->sha_ctxt.diglen);
mutex_unlock(&hash_access_lock);
if (copy_to_user((void __user *)arg, &qcedev_areq.sha_op_req,
if (copy_to_user((void __user *)arg, &qcedev_areq->sha_op_req,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
handle->sha_ctxt.init_done = false;
Expand All @@ -1830,23 +1834,23 @@ static inline long qcedev_ioctl(struct file *file,
{
struct scatterlist sg_src;

if (copy_from_user(&qcedev_areq.sha_op_req,
if (copy_from_user(&qcedev_areq->sha_op_req,
(void __user *)arg,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
mutex_lock(&hash_access_lock);
if (qcedev_check_sha_params(&qcedev_areq.sha_op_req, podev)) {
if (qcedev_check_sha_params(&qcedev_areq->sha_op_req, podev)) {
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
qcedev_areq.op_type = QCEDEV_CRYPTO_OPER_SHA;
qcedev_hash_init(&qcedev_areq, handle, &sg_src);
err = qcedev_hash_update(&qcedev_areq, handle, &sg_src);
qcedev_areq->op_type = QCEDEV_CRYPTO_OPER_SHA;
qcedev_hash_init(qcedev_areq, handle, &sg_src);
err = qcedev_hash_update(qcedev_areq, handle, &sg_src);
if (err) {
mutex_unlock(&hash_access_lock);
return err;
}
err = qcedev_hash_final(&qcedev_areq, handle);
err = qcedev_hash_final(qcedev_areq, handle);
if (err) {
mutex_unlock(&hash_access_lock);
return err;
Expand All @@ -1857,12 +1861,12 @@ static inline long qcedev_ioctl(struct file *file,
mutex_unlock(&hash_access_lock);
return -EINVAL;
}
qcedev_areq.sha_op_req.diglen = handle->sha_ctxt.diglen;
memcpy(&qcedev_areq.sha_op_req.digest[0],
qcedev_areq->sha_op_req.diglen = handle->sha_ctxt.diglen;
memcpy(&qcedev_areq->sha_op_req.digest[0],
&handle->sha_ctxt.digest[0],
handle->sha_ctxt.diglen);
mutex_unlock(&hash_access_lock);
if (copy_to_user((void __user *)arg, &qcedev_areq.sha_op_req,
if (copy_to_user((void __user *)arg, &qcedev_areq->sha_op_req,
sizeof(struct qcedev_sha_op_req)))
return -EFAULT;
}
Expand Down

0 comments on commit 534ad92

Please sign in to comment.