User: | Jiri Slaby |
Error type: | Double Lock |
Error type description: | Some lock is locked twice unintentionally in a sequence |
File location: | fs/inotify.c |
Line in file: | 875 |
Project: | Linux Kernel |
Project version: | 2.6.28 |
Tools: |
Clang Static Analyzer
(3.0)
Smatch (1.59) |
Entered: | 2012-04-17 12:29:30 UTC |
845} 846 847/** 848 * inotify_rm_wd - remove a watch from an inotify instance 849 * @ih: inotify handle 850 * @wd: watch descriptor to remove 851 * 852 * Can sleep. 853 */ 854int inotify_rm_wd(struct inotify_handle *ih, u32 wd) 855{ 856 struct inotify_watch *watch; 857 struct super_block *sb; 858 struct inode *inode; 859 int how; 860 861 mutex_lock(&ih->mutex); 862 watch = idr_find(&ih->idr, wd); 863 if (unlikely(!watch)) { 864 mutex_unlock(&ih->mutex); 865 return -EINVAL; 866 } 867 sb = watch->inode->i_sb; 868 how = pin_to_kill(ih, watch); 869 if (!how) 870 return 0; 871 872 inode = watch->inode; 873 874 mutex_lock(&inode->inotify_mutex); 875 mutex_lock(&ih->mutex); 876 877 /* make sure that we did not race */ 878 if (likely(idr_find(&ih->idr, wd) == watch)) 879 inotify_remove_watch_locked(ih, watch); 880 881 mutex_unlock(&ih->mutex); 882 mutex_unlock(&inode->inotify_mutex); 883 unpin_and_kill(watch, how); 884 885 return 0;