summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-06-26 04:31:23 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2018-06-26 04:31:23 -0700
commita0209303bb669a263fa7650a1de9d61d3e1ca7f3 (patch)
tree0d6e9a3722290b8e9036f505eff318db24cd476c
parentf9d7e36b73a258362f0f455be10825c2ec27e420 (diff)
parentcc6897b4ca7f086ef37eba598bed3bf09c0ab170 (diff)
Merge "msm: vidc: Fix accessing invalid instance"
-rw-r--r--drivers/media/platform/msm/vidc/msm_vidc_common.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index 3af6e53b21e7..ee3cfb88855c 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -2614,6 +2614,7 @@ int msm_comm_check_core_init(struct msm_vidc_core *core)
int rc = 0;
struct hfi_device *hdev;
struct msm_vidc_inst *inst = NULL;
+ int dref = 0;
mutex_lock(&core->lock);
if (core->state >= VIDC_CORE_INIT_DONE) {
@@ -2637,11 +2638,16 @@ int msm_comm_check_core_init(struct msm_vidc_core *core)
* Just grab one of the inst from instances list and
* use it.
*/
- inst = list_first_entry(&core->instances,
+ inst = list_first_entry_or_null(&core->instances,
struct msm_vidc_inst, list);
+ if (inst)
+ dref = kref_get_unless_zero(&inst->kref);
mutex_unlock(&core->lock);
- msm_comm_print_debug_info(inst);
+ if (dref) {
+ msm_comm_print_debug_info(inst);
+ put_inst(inst);
+ }
mutex_lock(&core->lock);
BUG_ON(msm_vidc_debug_timeout);