Skip to content

Commit

Permalink
intel_th: msu: Release resources on read error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Laurent FERT authored and Greg Kroah-Hartman committed Feb 20, 2016
1 parent e4eca2a commit 2bed074
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/hwtracing/intel_th/msu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2bed074

Please sign in to comment.