msm: BA: Fix race condition with v4l2 event handler

The v4l2 event handler struct should be initialized
before added to the dev_ctxt->instances list.
The v4l2 event handler struct should be de-initialized
after we remove inst from the core->instances list.

Change-Id: I1faf6bab4232bbcd2ca567a9a11b0c8faa2f45ce
Signed-off-by: Domi Papoi <dpapoi@codeaurora.org>
This commit is contained in:
Domi Papoi 2016-02-12 13:22:31 -05:00 committed by Gerrit - the friendly Code Review server
parent 96befb971f
commit bcfb8150a0

View file

@ -773,6 +773,8 @@ void *msm_ba_open(const struct msm_ba_ext_ops *ext_ops)
inst->sd = list_first_entry(&(inst->dev_ctxt->v4l2_dev.subdevs),
struct v4l2_subdev, list);
msm_ba_setup_event_queue(inst, dev_ctxt->vdev);
mutex_lock(&dev_ctxt->dev_cs);
list_add_tail(&inst->list, &dev_ctxt->instances);
mutex_unlock(&dev_ctxt->dev_cs);
@ -788,8 +790,6 @@ void *msm_ba_open(const struct msm_ba_ext_ops *ext_ops)
inst->ext_ops = ext_ops;
msm_ba_setup_event_queue(inst, dev_ctxt->vdev);
return inst;
}
EXPORT_SYMBOL(msm_ba_open);
@ -805,7 +805,6 @@ int msm_ba_close(void *instance)
if (!inst)
return -EINVAL;
v4l2_fh_del(&inst->event_handler);
dev_ctxt = inst->dev_ctxt;
mutex_lock(&dev_ctxt->dev_cs);
@ -818,6 +817,10 @@ int msm_ba_close(void *instance)
mutex_unlock(&dev_ctxt->dev_cs);
msm_ba_ctrl_deinit(inst);
v4l2_fh_del(&inst->event_handler);
v4l2_fh_exit(&inst->event_handler);
debugfs_remove_recursive(inst->debugfs_root);
dprintk(BA_DBG, "Closed BA instance: %p", inst);