Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b162c2a authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "crypto: fix pointer dereference"

parents 5114f6e9 fbde0587
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2016, 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
@@ -239,6 +239,10 @@ static void req_done(unsigned long data)
		if (!list_empty(&podev->ready_commands)) {
			new_req = container_of(podev->ready_commands.next,
						struct ota_async_req, rlist);
			if (NULL == new_req) {
				pr_err("ota_crypto: req_done, new_req = NULL");
				return;
			}
			list_del(&new_req->rlist);
			pqce->active_command = new_req;
			spin_unlock_irqrestore(&podev->lock, flags);
+20 −3
Original line number Diff line number Diff line
@@ -213,8 +213,13 @@ static int count_sg(struct scatterlist *sg, int nbytes)
{
	int i;

	for (i = 0; nbytes > 0; i++, sg = scatterwalk_sg_next(sg))
	for (i = 0; nbytes > 0; i++, sg = scatterwalk_sg_next(sg)) {
		if (NULL == sg) {
			pr_err("qce50.c: count_sg, sg = NULL");
			break;
		}
		nbytes -= sg->length;
	}
	return i;
}

@@ -224,6 +229,10 @@ static int qce_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
	int i;

	for (i = 0; i < nents; ++i) {
		if (NULL == sg) {
			pr_err("qce50.c: qce_dma_map_sg, sg = NULL");
			break;
		}
		dma_map_sg(dev, sg, 1, direction);
		sg = scatterwalk_sg_next(sg);
	}
@@ -237,6 +246,10 @@ static int qce_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
	int i;

	for (i = 0; i < nents; ++i) {
		if (NULL == sg) {
			pr_err("qce50.c: qce_dma_unmap_sg, sg = NULL");
			break;
		}
		dma_unmap_sg(dev, sg, 1, direction);
		sg = scatterwalk_sg_next(sg);
	}
@@ -339,7 +352,7 @@ static int _ce_setup_hash(struct qce_device *pce_dev,
				struct qce_sha_req *sreq,
				struct qce_cmdlist_info *cmdlistinfo)
{
	uint32_t auth32[SHA256_DIGEST_SIZE / sizeof(uint32_t)];
	uint32_t auth32[(SHA256_DIGEST_SIZE / sizeof(uint32_t))+1];
	uint32_t diglen;
	int i;
	uint32_t mackey32[SHA_HMAC_KEY_SIZE/sizeof(uint32_t)] = {
@@ -1174,7 +1187,7 @@ static void _qce_dump_descr_fifos_dbg(struct qce_device *pce_dev, int req_info)
static int _ce_setup_hash_direct(struct qce_device *pce_dev,
				struct qce_sha_req *sreq)
{
	uint32_t auth32[SHA256_DIGEST_SIZE / sizeof(uint32_t)];
	uint32_t auth32[(SHA256_DIGEST_SIZE / sizeof(uint32_t))+1];
	uint32_t diglen;
	bool use_hw_key = false;
	bool use_pipe_key = false;
@@ -2428,6 +2441,10 @@ static int _qce_sps_add_sg_data(struct qce_device *pce_dev,
						sps_bam_pipe->iovec_count;

	while (nbytes > 0) {
		if (NULL == sg_src) {
			pr_err("qce50.c: _qce_sps_add_sg_data, sg_src = NULL");
			break;
		}
		len = min(nbytes, sg_dma_len(sg_src));
		nbytes -= len;
		addr = sg_dma_address(sg_src);
+20 −2
Original line number Diff line number Diff line
@@ -742,6 +742,10 @@ static size_t qcrypto_sg_copy_from_buffer(struct scatterlist *sgl,
	size_t offset, len;

	for (i = 0, offset = 0; i < nents; ++i) {
		if (NULL == sgl) {
			pr_err("qcrypto.c: qcrypto_sg_copy_from_buffer, sgl = NULL");
			break;
		}
		len = sg_copy_from_buffer(sgl, 1, buf, buflen);
		buf += len;
		buflen -= len;
@@ -759,6 +763,10 @@ static size_t qcrypto_sg_copy_to_buffer(struct scatterlist *sgl,
	size_t offset, len;

	for (i = 0, offset = 0; i < nents; ++i) {
		if (NULL == sgl) {
			pr_err("qcrypto.c: qcrypto_sg_copy_from_buffer, sgl = NULL");
			break;
		}
		len = sg_copy_to_buffer(sgl, 1, buf, buflen);
		buf += len;
		buflen -= len;
@@ -4011,6 +4019,10 @@ static int _sha_update(struct ahash_request *req, uint32_t sha_block_size)
			break;
		len += sg_last->length;
		sg_last = scatterwalk_sg_next(sg_last);
		if (NULL == sg_last) {
			pr_err("qcrypto.c: _sha_update, sg_last = NULL");
			break;
		}
	}
	if (rctx->trailing_buf_len) {
		if (cp->ce_support.aligned_only)  {
@@ -4032,7 +4044,10 @@ static int _sha_update(struct ahash_request *req, uint32_t sha_block_size)
			req->src = rctx->sg;
			sg_mark_end(&rctx->sg[0]);
		} else {
			if (sg_last)
				sg_mark_end(sg_last);
			else
				pr_err("qcrypto: _sha_update, sg_last= NULL");
			memset(rctx->sg, 0, sizeof(rctx->sg));
			sg_set_buf(&rctx->sg[0], staging,
						rctx->trailing_buf_len);
@@ -4041,7 +4056,10 @@ static int _sha_update(struct ahash_request *req, uint32_t sha_block_size)
			req->src = rctx->sg;
		}
	} else
		if (sg_last)
			sg_mark_end(sg_last);
		else
			pr_err("qcrypto.c: _sha_update, sg_last = NULL");

	req->nbytes = nbytes;
	rctx->trailing_buf_len = trailing_buf_len;