Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ba2b249 authored by Guchun Chen's avatar Guchun Chen Committed by Dhaval Patel
Browse files

drm: msm: fix list corruption problem



When multiple worker threads compete to update event_list, with current
vblank_ctrl_worker mechanism, there is one risk which can casue list node
is deleted for twice. This is because, due to the protected scope by
the spin_lock, mutex can exit when one thread is transvering the list,
but another queue thread may continue to add new event to the list.
This brings conflict risk. This patch is to correct this.

Change-Id: Ice31462d196c57ce18d7b998c1a1f0b7feeb08fc
Signed-off-by: default avatarXiaowen Wu <wxiaowen@codeaurora.org>
Signed-off-by: default avatarGuchun Chen <guchunc@codeaurora.org>
parent f92f804a
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -215,12 +215,16 @@ static void vblank_ctrl_worker(struct kthread_work *work)
	struct msm_kms *kms = priv->kms;
	struct vblank_event *vbl_ev, *tmp;
	unsigned long flags;
	LIST_HEAD(tmp_head);

	spin_lock_irqsave(&vbl_ctrl->lock, flags);
	list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) {
		list_del(&vbl_ev->node);
		list_add_tail(&vbl_ev->node, &tmp_head);
	}
	spin_unlock_irqrestore(&vbl_ctrl->lock, flags);

	list_for_each_entry_safe(vbl_ev, tmp, &tmp_head, node) {
		if (vbl_ev->enable)
			kms->funcs->enable_vblank(kms,
						priv->crtcs[vbl_ev->crtc_id]);
@@ -229,11 +233,7 @@ static void vblank_ctrl_worker(struct kthread_work *work)
						priv->crtcs[vbl_ev->crtc_id]);

		kfree(vbl_ev);

		spin_lock_irqsave(&vbl_ctrl->lock, flags);
	}

	spin_unlock_irqrestore(&vbl_ctrl->lock, flags);
}

static int vblank_ctrl_queue_work(struct msm_drm_private *priv,