Skip to contentSkip to conversation

videobuf2-core: take mmap_sem before calling __qbuf_userptr

PATCH New Hans Verkuil 1 participant 1 message Aug 25, 2014 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 videobuf2-core: take mmap_sem before calling __qbuf_userptr

(Changes since v2: dropped local variable as suggested by Laurent)

Commit f035eb4e976ef5a059e30bc91cfd310ff030a7d3 (videobuf2: fix lockdep warning) unfortunately removed the mmap_sem lock that is needed around the call to __qbuf_userptr. Amazingly nobody noticed this (especially me as the author) until Jan Kara pointed this out to me.

---
 drivers/media/v4l2-core/videobuf2-core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/v4l2-core/videobuf2-core.c +2 -0
index 5b808e2..ce59962b 100644
@@ -1627,7 +1627,9 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
 		ret = __qbuf_mmap(vb, b);
 		break;
 	case V4L2_MEMORY_USERPTR:
+		down_read(&current->mm->mmap_sem);
 		ret = __qbuf_userptr(vb, b);
+		up_read(&current->mm->mmap_sem);
 		break;
 	case V4L2_MEMORY_DMABUF:
 		ret = __qbuf_dmabuf(vb, b);
Signature · 1 line
2.1.0.rc1