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

Commit bc6da1e7 authored by Ramesh V's avatar Ramesh V
Browse files

msm: camera: avoid race condition during session stream destroy



add proper lock/unlock to avoid race condition at the time of session
stream destroy also initialize the stream as NULL after free.

Change-Id: Ib8540b7c90e202760f064cada02ecfacbb85e8b0
Signed-off-by: default avatarRamesh V <ramev@codeaurora.org>
parent 3ce8d9c2
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -250,8 +250,9 @@ void msm_delete_stream(unsigned int session_id, unsigned int stream_id)
	spin_lock_irqsave(&(session->stream_q.lock), flags);
	list_del_init(&stream->list);
	session->stream_q.len--;
	kfree(stream);
	stream = NULL;
	spin_unlock_irqrestore(&(session->stream_q.lock), flags);
	kzfree(stream);
}

static void msm_sd_unregister_subdev(struct video_device *vdev)
@@ -475,8 +476,12 @@ static inline int __msm_sd_notify_freeze_subdevs(struct msm_sd_subdev *msm_sd)
static inline int __msm_destroy_session_streams(void *d1, void *d2)
{
	struct msm_stream *stream = d1;
	unsigned long flags;

	pr_err("%s: Error: Destroyed list is not empty\n", __func__);
	spin_lock_irqsave(&stream->stream_lock, flags);
	INIT_LIST_HEAD(&stream->queued_list);
	spin_unlock_irqrestore(&stream->stream_lock, flags);
	return 0;
}