From: Sylwester Nawrocki <s.nawrocki@xxxxxxxxxxx> Fix copying unions and preserve pointer to the plane array in buf_sp_to_mp() and buf_mp_to_sp(). Signed-off-by: Sylwester Nawrocki <s.nawrocki@xxxxxxxxxxx> Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> --- drivers/media/video/v4l2-ioctl.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) 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; } -- 1.7.1.569.g6f426 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html