OSDN Git Service

qseecom: fix a common lib loading issue
authorZhen Kong <zkong@codeaurora.org>
Wed, 18 Oct 2017 17:27:20 +0000 (10:27 -0700)
committerGerrit - the friendly Code Review server <code-review@localhost>
Sat, 2 Dec 2017 16:17:10 +0000 (08:17 -0800)
cmnlib_ion_handle is only used within qseecom_load_commonlib_image()
and is not a shared resource, so change it to a local variable and
avoid potential reuse or free by another thread in case of reentrancy.

Change-Id: I9e1f25cd024a19a7379b7409bdc6521bcd8bcae5
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
drivers/misc/qseecom.c

index 8c48a5c..aba9d26 100644 (file)
@@ -252,7 +252,6 @@ struct qseecom_control {
        bool  whitelist_support;
        bool  commonlib_loaded;
        bool  commonlib64_loaded;
-       struct ion_handle *cmnlib_ion_handle;
        struct ce_hw_usage_info ce_info;
 
        int qsee_bw_count;
@@ -4291,6 +4290,7 @@ static int qseecom_load_commonlib_image(struct qseecom_dev_handle *data,
        void *cmd_buf = NULL;
        size_t cmd_len;
        uint32_t app_arch = 0;
+       struct ion_handle *cmnlib_ion_handle = NULL;
 
        if (!cmnlib_name) {
                pr_err("cmnlib_name is NULL\n");
@@ -4305,7 +4305,7 @@ static int qseecom_load_commonlib_image(struct qseecom_dev_handle *data,
        if (__qseecom_get_fw_size(cmnlib_name, &fw_size, &app_arch))
                return -EIO;
 
-       ret = __qseecom_allocate_img_data(&qseecom.cmnlib_ion_handle,
+       ret = __qseecom_allocate_img_data(&cmnlib_ion_handle,
                                                &img_data, fw_size, &pa);
        if (ret)
                return -EIO;
@@ -4346,7 +4346,7 @@ static int qseecom_load_commonlib_image(struct qseecom_dev_handle *data,
                goto exit_unregister_bus_bw_need;
        }
 
-       ret = msm_ion_do_cache_op(qseecom.ion_clnt, qseecom.cmnlib_ion_handle,
+       ret = msm_ion_do_cache_op(qseecom.ion_clnt, cmnlib_ion_handle,
                                img_data, fw_size,
                                ION_IOC_CLEAN_INV_CACHES);
        if (ret) {
@@ -4394,7 +4394,7 @@ exit_unregister_bus_bw_need:
        }
 
 exit_free_img_data:
-       __qseecom_free_img_data(&qseecom.cmnlib_ion_handle);
+       __qseecom_free_img_data(&cmnlib_ion_handle);
        return ret;
 }