[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20111207160826.477141898@clark.kroah.org>
Date: Wed, 07 Dec 2011 08:07:07 -0800
From: Greg KH <gregkh@...e.de>
To: <linux-kernel@...r.kernel.org>, <stable@...r.kernel.org>
Cc: <torvalds@...ux-foundation.org>, <akpm@...ux-foundation.org>,
<alan@...rguk.ukuu.org.uk>, Alessandro Rubini <rubini@...dd.com>,
Federico Vaga <federico.vaga@...il.com>
Subject: [47/80] Staging: comedi: fix mmap_count
3.0-stable review patch. If anyone has any objections, please let me know.
------------------
From: Federico Vaga <federico.vaga@...il.com>
commit df30b21cb0eed5ba8a8e0cdfeebc66ba8cde821d upstream.
In comedi_fops, mmap_count is decremented at comedi_vm_ops->close but
it is not incremented at comedi_vm_ops->open. This may result in a negative
counter. The patch introduces the open method to keep the counter
consistent.
The bug was triggerd by this sample code:
mmap(0, ...., comedi_fd);
fork();
exit(0);
Acked-by: Alessandro Rubini <rubini@...dd.com>
Signed-off-by: Federico Vaga <federico.vaga@...il.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de>
---
drivers/staging/comedi/comedi_fops.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1432,7 +1432,21 @@ static int do_cancel(struct comedi_devic
return ret;
}
-static void comedi_unmap(struct vm_area_struct *area)
+
+static void comedi_vm_open(struct vm_area_struct *area)
+{
+ struct comedi_async *async;
+ struct comedi_device *dev;
+
+ async = area->vm_private_data;
+ dev = async->subdevice->device;
+
+ mutex_lock(&dev->mutex);
+ async->mmap_count++;
+ mutex_unlock(&dev->mutex);
+}
+
+static void comedi_vm_close(struct vm_area_struct *area)
{
struct comedi_async *async;
struct comedi_device *dev;
@@ -1446,7 +1460,8 @@ static void comedi_unmap(struct vm_area_
}
static struct vm_operations_struct comedi_vm_ops = {
- .close = comedi_unmap,
+ .open = comedi_vm_open,
+ .close = comedi_vm_close,
};
static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists