drm: Fix memory leak at error path of drm_read()
authorTakashi Iwai <tiwai@suse.de>
Thu, 4 Dec 2014 10:56:42 +0000 (11:56 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 4 Dec 2014 12:28:42 +0000 (13:28 +0100)
Note that the read manpages explicitly states that the read position
is undefined on error. Since EFAULT is just a userspace bug we are
therefore fine with just dropping the event on the floor.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
[danvet: Add note that just dropping the event is ok.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_fops.c

index 91e1105..0b9514b 100644 (file)
@@ -527,6 +527,7 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
                if (copy_to_user(buffer + total,
                                 e->event, e->event->length)) {
                        total = -EFAULT;
+                       e->destroy(e);
                        break;
                }