]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/crypto/ccp/ccp-crypto-aes-cmac.c
Merge remote-tracking branch 'omap/for-next'
[karo-tx-linux.git] / drivers / crypto / ccp / ccp-crypto-aes-cmac.c
index ea7e8446956a62ec33f0a0db8ead012ffbb56787..d89f20c04266b31ad85bf82ccf5a2169c52ba727 100644 (file)
@@ -118,10 +118,19 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes,
        if (rctx->buf_count) {
                sg_init_one(&rctx->buf_sg, rctx->buf, rctx->buf_count);
                sg = ccp_crypto_sg_table_add(&rctx->data_sg, &rctx->buf_sg);
+               if (!sg) {
+                       ret = -EINVAL;
+                       goto e_free;
+               }
        }
 
-       if (nbytes)
+       if (nbytes) {
                sg = ccp_crypto_sg_table_add(&rctx->data_sg, req->src);
+               if (!sg) {
+                       ret = -EINVAL;
+                       goto e_free;
+               }
+       }
 
        if (need_pad) {
                int pad_length = block_size - (len & (block_size - 1));
@@ -132,6 +141,10 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes,
                rctx->pad[0] = 0x80;
                sg_init_one(&rctx->pad_sg, rctx->pad, pad_length);
                sg = ccp_crypto_sg_table_add(&rctx->data_sg, &rctx->pad_sg);
+               if (!sg) {
+                       ret = -EINVAL;
+                       goto e_free;
+               }
        }
        if (sg) {
                sg_mark_end(sg);
@@ -162,6 +175,11 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes,
 
        ret = ccp_crypto_enqueue_request(&req->base, &rctx->cmd);
 
+       return ret;
+
+e_free:
+       sg_free_table(&rctx->data_sg);
+
        return ret;
 }