]> git.karo-electronics.de Git - linux-beck.git/commitdiff
crypto: qat - fix leak on error path
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Tue, 6 Sep 2016 10:18:51 +0000 (11:18 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 13 Sep 2016 12:27:22 +0000 (20:27 +0800)
Fix a memory leak in an error path in uc loader.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_common/qat_uclo.c

index 9b961b37a282d6d59797fba68c5634e0b645f17e..e2454d90d9498e4e6ee1545a7e4e88ba56b5368a 100644 (file)
@@ -967,10 +967,6 @@ static int qat_uclo_parse_uof_obj(struct icp_qat_fw_loader_handle *handle)
        struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
        unsigned int ae;
 
-       obj_handle->uword_buf = kcalloc(UWORD_CPYBUF_SIZE, sizeof(uint64_t),
-                                       GFP_KERNEL);
-       if (!obj_handle->uword_buf)
-               return -ENOMEM;
        obj_handle->encap_uof_obj.beg_uof = obj_handle->obj_hdr->file_buff;
        obj_handle->encap_uof_obj.obj_hdr = (struct icp_qat_uof_objhdr *)
                                             obj_handle->obj_hdr->file_buff;
@@ -982,6 +978,10 @@ static int qat_uclo_parse_uof_obj(struct icp_qat_fw_loader_handle *handle)
                pr_err("QAT: UOF incompatible\n");
                return -EINVAL;
        }
+       obj_handle->uword_buf = kcalloc(UWORD_CPYBUF_SIZE, sizeof(uint64_t),
+                                       GFP_KERNEL);
+       if (!obj_handle->uword_buf)
+               return -ENOMEM;
        obj_handle->ustore_phy_size = ICP_QAT_UCLO_MAX_USTORE;
        if (!obj_handle->obj_hdr->file_buff ||
            !qat_uclo_map_str_table(obj_handle->obj_hdr, ICP_QAT_UOF_STRT,