From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: laurent.pinchart@ideasonboard.com
Cc: linux-media@vger.kernel.org, chiranjeevi.rapolu@intel.com
Subject: [PATCH 1/1] uvc: Avoid NULL pointer dereference at the end of streaming
Date: Tue, 29 Jan 2019 23:49:44 +0200 [thread overview]
Message-ID: <20190129214944.16875-1-sakari.ailus@linux.intel.com> (raw)
The UVC video driver converts the timestamp from hardware specific unit to
one known by the kernel at the time when the buffer is dequeued. This is
fine in general, but the streamoff operation consists of the following
steps (among other things):
1. uvc_video_clock_cleanup --- the hardware clock sample array is
released and the pointer to the array is set to NULL,
2. buffers in active state are returned to the user and
3. buf_finish callback is called on buffers that are prepared. buf_finish
includes calling uvc_video_clock_update that accesses the hardware
clock sample array.
The above is serialised by a queue specific mutex. Address the problem by
skipping the clock conversion if the hardware clock sample array is
already released.
Reported-by: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
Tested-by: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Hi Laurent,
This seems like something that's been out there for a while... I'll figure
out soon which stable kernels should receive it, if any.
drivers/media/usb/uvc/uvc_video.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 84525ff047450..a30c5e1893e72 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -676,6 +676,13 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
if (!uvc_hw_timestamps_param)
return;
+ /*
+ * We may get called if there are buffers done but not dequeued by the
+ * user. Just bail out in that case.
+ */
+ if (!clock->samples)
+ return;
+
spin_lock_irqsave(&clock->lock, flags);
if (clock->count < clock->size)
--
2.11.0
next reply other threads:[~2019-01-29 21:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 21:49 Sakari Ailus [this message]
2019-01-30 9:17 ` [PATCH 1/1] uvc: Avoid NULL pointer dereference at the end of streaming Laurent Pinchart
2019-01-30 9:22 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190129214944.16875-1-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=chiranjeevi.rapolu@intel.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox