diff options
author | Hans de Goede <hdegoede@redhat.com> | 2011-10-26 04:40:27 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-08 07:29:29 -0500 |
commit | 78c87e863bb3350426fecd14912fd0a546c58ec0 (patch) | |
tree | bc50ec4ccf077a2753ef23a4d95c1f182b6a66a4 /drivers | |
parent | b36b505965e374b284166c2e6b9c1d369d663ea9 (diff) |
[media] v4l2-event: Remove pending events from fh event queue when unsubscribing
The kev pointers inside the pending events queue (the available queue) of the
fh point to data inside the sev, unsubscribing frees the sev, thus making these
pointers point to freed memory!
This patch fixes these dangling pointers in the available queue by removing
all matching pending events on unsubscription.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/v4l2-event.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c index 9f56f18d509f..4d01f17497f6 100644 --- a/drivers/media/video/v4l2-event.c +++ b/drivers/media/video/v4l2-event.c | |||
@@ -285,6 +285,7 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh, | |||
285 | { | 285 | { |
286 | struct v4l2_subscribed_event *sev; | 286 | struct v4l2_subscribed_event *sev; |
287 | unsigned long flags; | 287 | unsigned long flags; |
288 | int i; | ||
288 | 289 | ||
289 | if (sub->type == V4L2_EVENT_ALL) { | 290 | if (sub->type == V4L2_EVENT_ALL) { |
290 | v4l2_event_unsubscribe_all(fh); | 291 | v4l2_event_unsubscribe_all(fh); |
@@ -295,6 +296,11 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh, | |||
295 | 296 | ||
296 | sev = v4l2_event_subscribed(fh, sub->type, sub->id); | 297 | sev = v4l2_event_subscribed(fh, sub->type, sub->id); |
297 | if (sev != NULL) { | 298 | if (sev != NULL) { |
299 | /* Remove any pending events for this subscription */ | ||
300 | for (i = 0; i < sev->in_use; i++) { | ||
301 | list_del(&sev->events[sev_pos(sev, i)].list); | ||
302 | fh->navailable--; | ||
303 | } | ||
298 | list_del(&sev->list); | 304 | list_del(&sev->list); |
299 | sev->fh = NULL; | 305 | sev->fh = NULL; |
300 | } | 306 | } |