From 8c0d44e250735b09e255ce0483c47eb2f68d3fa7 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Mon, 14 Jan 2013 15:22:55 -0300 Subject: [media] uvcvideo: Replace memcpy with struct assignment This kind of memcpy() is error-prone. Its replacement with a struct assignment is prefered because it's type-safe and much easier to read. Signed-off-by: Peter Senna Tschudin Signed-off-by: Ezequiel Garcia Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_v4l2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/media/usb/uvc/uvc_v4l2.c') diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 68d59b527492..97a4ffde5d6f 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -315,7 +315,7 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream, goto done; } - memcpy(&stream->ctrl, &probe, sizeof probe); + stream->ctrl = probe; stream->cur_format = format; stream->cur_frame = frame; @@ -387,7 +387,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream, return -EBUSY; } - memcpy(&probe, &stream->ctrl, sizeof probe); + probe = stream->ctrl; probe.dwFrameInterval = uvc_try_frame_interval(stream->cur_frame, interval); @@ -398,7 +398,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream, return ret; } - memcpy(&stream->ctrl, &probe, sizeof probe); + stream->ctrl = probe; mutex_unlock(&stream->mutex); /* Return the actual frame period. */ -- cgit v1.2.3 From a82a45f65377b05fe8cd3167c7b0a70c508356b8 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 10 Jan 2013 07:04:55 -0300 Subject: [media] uvcvideo: Fix race of open and suspend in error case Ming Lei reported: IMO, there is a minor fault in the error handling path of uvc_status_start() inside uvc_v4l2_open(), and the 'users' count should have been decreased before usb_autopm_put_interface(). In theory, a [URB resubmission] warning can be triggered when the device is opened just between usb_autopm_put_interface() and atomic_dec(&stream->dev->users). The fix is trivial. Reported-by: Ming Lei Signed-off-by: Oliver Neukum Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/usb/uvc/uvc_v4l2.c') diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 97a4ffde5d6f..b2dc32623a71 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -501,8 +501,8 @@ static int uvc_v4l2_open(struct file *file) if (atomic_inc_return(&stream->dev->users) == 1) { ret = uvc_status_start(stream->dev); if (ret < 0) { - usb_autopm_put_interface(stream->dev->intf); atomic_dec(&stream->dev->users); + usb_autopm_put_interface(stream->dev->intf); kfree(handle); return ret; } -- cgit v1.2.3