From: Laurent FERT Date: Mon, 15 Feb 2016 17:11:57 +0000 (+0200) Subject: intel_th: msu: Release resources on read error X-Git-Tag: v4.14-rc1~3637^2~65 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2bed074aade2caa9c350121837c55189a8fd197e;p=platform%2Fkernel%2Flinux-rpi.git intel_th: msu: Release resources on read error 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 Signed-off-by: Alexander Shishkin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index 3c793bb..d9d6022 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -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;