diff mbox

[1/2] linux-generic: handle copy error in odp_crypto_operation

Message ID 1424102658-26557-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Feb. 16, 2015, 4:04 p.m. UTC
In _odp_packet_copy_to_packet copying of packet can fail,
with check for enought room in the packet. That may happen due
to allocation error or possible memory corruption. Just call
ODP_ABORT here.

https://bugs.linaro.org/show_bug.cgi?id=1054
CID 85004:  Unchecked return value  (CHECKED_RETURN)
Calling "_odp_packet_copy_to_packet" without checking return value
	(as is done elsewhere 5 out of 6 times).

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_crypto.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index bc0f961..fb1e3fc 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -355,6 +355,7 @@  odp_crypto_operation(odp_crypto_op_params_t *params,
 	enum crypto_alg_err rc_auth = ODP_CRYPTO_ALG_ERR_NONE;
 	odp_crypto_generic_session_t *session;
 	odp_crypto_op_result_t local_result;
+	int ret;
 
 	session = (odp_crypto_generic_session_t *)(intptr_t)params->session;
 
@@ -367,8 +368,13 @@  odp_crypto_operation(odp_crypto_op_params_t *params,
 	if (params->pkt != params->out_pkt) {
 		if (odp_unlikely(ODP_PACKET_INVALID == params->out_pkt))
 			ODP_ABORT();
-		_odp_packet_copy_to_packet(params->pkt, 0, params->out_pkt, 0,
-					   odp_packet_len(params->pkt));
+		ret = _odp_packet_copy_to_packet(params->pkt,
+						 0,
+						 params->out_pkt,
+						 0,
+						 odp_packet_len(params->pkt));
+		if (odp_unlikely(ret))
+			ODP_ABORT();
 		_odp_packet_copy_md_to_packet(params->pkt, params->out_pkt);
 		odp_packet_free(params->pkt);
 		params->pkt = ODP_PACKET_INVALID;