]> git.karo-electronics.de Git - linux-beck.git/commitdiff
intel_th: msu: Release resources on read error
authorLaurent FERT <laurent.fert@intel.com>
Mon, 15 Feb 2016 17:11:57 +0000 (19:11 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Feb 2016 22:09:14 +0000 (14:09 -0800)
Right now, reading from msc character device will leak its's user count
on read error.

This patch makes sure resources are released when there is no data left
to read from the buffer.

Signed-off-by: Laurent FERT <laurent.fert@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/intel_th/msu.c

index 3c793bbf6ab206ea8b48a1a2d0780f78e3d7d31a..d9d6022c5aca42bbf959d214abb76b5ee3fe8704 100644 (file)
@@ -1112,12 +1112,11 @@ static ssize_t intel_th_msc_read(struct file *file, char __user *buf,
                size = msc->nr_pages << PAGE_SHIFT;
 
        if (!size)
-               return 0;
+               goto put_count;
 
-       if (off >= size) {
-               len = 0;
+       if (off >= size)
                goto put_count;
-       }
+
        if (off + len >= size)
                len = size - off;