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

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

Merge "crypto: msm: Verify source and destination data lengths"

parents 060948e7 fe0ab0cc
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -1644,6 +1644,9 @@ error:
static int qcedev_check_cipher_params(struct qcedev_cipher_op_req *req,
						struct qcedev_control *podev)
{
	uint32_t total = 0;
	uint32_t i;

	if (req->use_pmem) {
		pr_err("%s: Use of PMEM is not supported\n", __func__);
		goto error;
@@ -1695,7 +1698,22 @@ static int qcedev_check_cipher_params(struct qcedev_cipher_op_req *req,
			goto error;
		}
	}

	/* Check for sum of all dst length is equal to data_len  */
	for (i = 0; (i < QCEDEV_MAX_BUFFERS) && (total < req->data_len); i++)
		total += req->vbuf.dst[i].len;
	if (total != req->data_len) {
		pr_err("%s: Total (i=%d) dst(%d) buf size != data_len (%d)\n",
			__func__, i, total, req->data_len);
		goto error;
	}
	/* Check for sum of all src length is equal to data_len  */
	for (i = 0, total = 0; i < req->entries; i++)
		total += req->vbuf.src[i].len;
	if (total != req->data_len) {
		pr_err("%s: Total src(%d) buf size != data_len (%d)\n",
			__func__, total, req->data_len);
		goto error;
	}
	return 0;
error:
	return -EINVAL;