diff mbox

[06/13] v4l: v4l2-ioctl: Fix conversion between multiplane and singleplane buffers

Message ID 1293025239-9977-7-git-send-email-m.szyprowski@samsung.com (mailing list archive)
State RFC
Headers show

Commit Message

Marek Szyprowski Dec. 22, 2010, 1:40 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index fee8b94..60793d6 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -762,16 +762,20 @@  static int fmt_mp_to_sp(const struct v4l2_format *f_mp,
 static int buf_sp_to_mp(const struct v4l2_buffer *b_sp,
 			struct v4l2_buffer *b_mp)
 {
+	struct v4l2_plane *planes;
 	int ret;
 
+	planes = b_mp->m.planes;
 	memcpy(b_mp, b_sp, sizeof *b_mp);
+	b_mp->m.planes = planes;
+
 	ret = type_sp_to_mp(b_sp->type, &b_mp->type);
 	if (ret)
 		return ret;
 	b_mp->m.planes[0].length = b_sp->length;
 	b_mp->m.planes[0].bytesused = b_mp->bytesused;
 	b_mp->length = 1;
-	memcpy(&b_mp->m.planes[0].m, &b_sp->m, sizeof(struct v4l2_plane));
+	memcpy(&b_mp->m.planes[0].m, &b_sp->m, sizeof(b_mp->m.planes[0].m));
 
 	return 0;
 }
@@ -785,9 +789,10 @@  static int buf_mp_to_sp(const struct v4l2_buffer *b_mp,
 	ret = type_mp_to_sp(b_mp->type, &b_sp->type);
 	if (ret)
 		return ret;
+
 	b_sp->length = b_mp->m.planes[0].length;
 	b_sp->bytesused = b_mp->m.planes[0].bytesused;
-	memcpy(&b_sp->m, &b_mp->m.planes[0].m, sizeof(struct v4l2_plane));
+	memcpy(&b_sp->m, &b_mp->m.planes[0].m, sizeof(b_sp->m));
 
 	return 0;
 }