crypto: msm: Add validation checks for memory cleanup

Add validation checks to handle memory freeing &
prevent NULL pointer access.

Change-Id: I6e82ea56754fb12b467d5ecb642411017c1e18c6
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
This commit is contained in:
Hariprasad Dhalinarasimha 2013-02-26 17:25:36 -08:00 committed by Stephen Boyd
parent 0b42973394
commit 9ac8304ebe
3 changed files with 17 additions and 0 deletions

View File

@ -1523,6 +1523,9 @@ static int _setup_cipher_aes_cmdlistptrs(struct qce_device *pdev,
}
break;
default:
pr_err("Unknown mode of operation %d received, exiting now\n",
mode);
return -EINVAL;
break;
}
@ -1686,6 +1689,8 @@ static int _setup_cipher_des_cmdlistptrs(struct qce_device *pdev,
}
break;
default:
pr_err("Unknown algorithms %d received, exiting now\n", alg);
return -EINVAL;
break;
}
@ -1893,6 +1898,8 @@ static int _setup_auth_cmdlistptrs(struct qce_device *pdev,
0, NULL);
break;
default:
pr_err("Unknown algorithms %d received, exiting now\n", alg);
return -EINVAL;
break;
}
@ -2247,6 +2254,10 @@ int qce_aead_req(void *handle, struct qce_req *q_req)
if (q_req->mode != QCE_MODE_CCM) {
ivsize = crypto_aead_ivsize(aead);
auth_cmdlistinfo = &pce_dev->ce_sps.cmdlistptr.aead_sha1_hmac;
if (auth_cmdlistinfo == NULL) {
pr_err("Received NULL cmdlist, exiting now\n");
return -EINVAL;
}
}
ce_burst_size = pce_dev->ce_sps.ce_burst_size;

View File

@ -595,6 +595,9 @@ static int start_sha_req(struct qcedev_control *podev)
sreq.authklen = qcedev_areq->sha_op_req.authklen;
break;
default:
pr_err("Algorithm %d not supported, exiting\n",
qcedev_areq->sha_op_req.alg);
return -EINVAL;
break;
};

View File

@ -1175,6 +1175,8 @@ static int _qcrypto_process_ahash(struct crypto_priv *cp,
sreq.authklen = SHA_HMAC_KEY_SIZE;
break;
default:
pr_err("Algorithm %d not supported, exiting", sha_ctx->alg);
ret = -1;
break;
};
ret = qce_process_sha_req(cp->qce, &sreq);
@ -1240,6 +1242,7 @@ static int _qcrypto_process_aead(struct crypto_priv *cp,
if (rctx->data == NULL) {
pr_err("Mem Alloc fail rctx->data, err %ld\n",
PTR_ERR(rctx->data));
kzfree(qreq.assoc);
return -ENOMEM;
}