From: James Simmons Date: Wed, 23 Mar 2016 23:22:40 +0000 (-0400) Subject: LU-6245 libcfs: fix racey module handling X-Git-Tag: 2.8.52~31 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=42cb962d3f15f827be739ac5d02692d2643c3e07 LU-6245 libcfs: fix racey module handling While working on the upstream client Greg pointed out the current why we handle libcfs module loading with psdev is very racy. This patch removes the possible race. Change-Id: Ic86aa9b0d426cc53a239ae81fc92db2d5a2b5c60 Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/18964 Reviewed-by: Frank Zago Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/linux/linux-module.c b/libcfs/libcfs/linux/linux-module.c index c4f578b..54be33a 100644 --- a/libcfs/libcfs/linux/linux-module.c +++ b/libcfs/libcfs/linux/linux-module.c @@ -149,27 +149,6 @@ failed: RETURN(err); } -static int -libcfs_psdev_open(struct inode * inode, struct file * file) -{ - if (!inode) - return -EINVAL; - - try_module_get(THIS_MODULE); - return 0; -} - -/* called when closing /dev/device */ -static int -libcfs_psdev_release(struct inode * inode, struct file * file) -{ - if (!inode) - return -EINVAL; - - module_put(THIS_MODULE); - return 0; -} - static long libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -188,9 +167,8 @@ libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } static struct file_operations libcfs_fops = { + .owner = THIS_MODULE, .unlocked_ioctl = libcfs_psdev_ioctl, - .open = libcfs_psdev_open, - .release = libcfs_psdev_release }; struct miscdevice libcfs_dev = {