aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-event.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/v4l2-event.c')
-rw-r--r--drivers/media/video/v4l2-event.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c
index 53b190cf225..c26ad963714 100644
--- a/drivers/media/video/v4l2-event.c
+++ b/drivers/media/video/v4l2-event.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/export.h>
32 33
33static unsigned sev_pos(const struct v4l2_subscribed_event *sev, unsigned idx) 34static unsigned sev_pos(const struct v4l2_subscribed_event *sev, unsigned idx)
34{ 35{
@@ -215,6 +216,9 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
215 unsigned long flags; 216 unsigned long flags;
216 unsigned i; 217 unsigned i;
217 218
219 if (sub->type == V4L2_EVENT_ALL)
220 return -EINVAL;
221
218 if (elems < 1) 222 if (elems < 1)
219 elems = 1; 223 elems = 1;
220 if (sub->type == V4L2_EVENT_CTRL) { 224 if (sub->type == V4L2_EVENT_CTRL) {
@@ -282,6 +286,7 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
282{ 286{
283 struct v4l2_subscribed_event *sev; 287 struct v4l2_subscribed_event *sev;
284 unsigned long flags; 288 unsigned long flags;
289 int i;
285 290
286 if (sub->type == V4L2_EVENT_ALL) { 291 if (sub->type == V4L2_EVENT_ALL) {
287 v4l2_event_unsubscribe_all(fh); 292 v4l2_event_unsubscribe_all(fh);
@@ -292,8 +297,12 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
292 297
293 sev = v4l2_event_subscribed(fh, sub->type, sub->id); 298 sev = v4l2_event_subscribed(fh, sub->type, sub->id);
294 if (sev != NULL) { 299 if (sev != NULL) {
300 /* Remove any pending events for this subscription */
301 for (i = 0; i < sev->in_use; i++) {
302 list_del(&sev->events[sev_pos(sev, i)].list);
303 fh->navailable--;
304 }
295 list_del(&sev->list); 305 list_del(&sev->list);
296 sev->fh = NULL;
297 } 306 }
298 307
299 spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); 308 spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);