[ovs-dev] [PATCH 3/7] datapath: Add owner to file_operations declaration.

Jesse Gross jesse at nicira.com
Wed Dec 29 23:41:31 UTC 2010


It's currently possible for operations on our character device to
be still running when we unload the module.  This will result in
an oops when the executing code is suddenly freed.  The chrdev
code has a way to avoid this by taking a reference on the module
every time the device is opened, which means that we can't be
unloaded as long as there is an open file descriptor and therefore
the possibility of an operation.  However, our file_operations
structure doesn't include an owner member, which prevents this
mechanism from working.  This adds one.

Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/datapath.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 1bf0520..67f6730 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -1989,6 +1989,7 @@ static unsigned int openvswitch_poll(struct file *file, poll_table *wait)
 }
 
 static struct file_operations openvswitch_fops = {
+	.owner = THIS_MODULE,
 	.read  = openvswitch_read,
 	.poll  = openvswitch_poll,
 	.unlocked_ioctl = openvswitch_ioctl,
-- 
1.7.1





More information about the dev mailing list