diff options
Diffstat (limited to 'fs/inotify.c')
-rw-r--r-- | fs/inotify.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/inotify.c b/fs/inotify.c index 1f50302849c5..732ec4bd5774 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
@@ -848,7 +848,11 @@ static int inotify_release(struct inode *ignored, struct file *file) | |||
848 | inode = watch->inode; | 848 | inode = watch->inode; |
849 | mutex_lock(&inode->inotify_mutex); | 849 | mutex_lock(&inode->inotify_mutex); |
850 | mutex_lock(&dev->mutex); | 850 | mutex_lock(&dev->mutex); |
851 | remove_watch_no_event(watch, dev); | 851 | |
852 | /* make sure we didn't race with another list removal */ | ||
853 | if (likely(idr_find(&dev->idr, watch->wd))) | ||
854 | remove_watch_no_event(watch, dev); | ||
855 | |||
852 | mutex_unlock(&dev->mutex); | 856 | mutex_unlock(&dev->mutex); |
853 | mutex_unlock(&inode->inotify_mutex); | 857 | mutex_unlock(&inode->inotify_mutex); |
854 | put_inotify_watch(watch); | 858 | put_inotify_watch(watch); |
@@ -890,8 +894,7 @@ static int inotify_ignore(struct inotify_device *dev, s32 wd) | |||
890 | mutex_lock(&dev->mutex); | 894 | mutex_lock(&dev->mutex); |
891 | 895 | ||
892 | /* make sure that we did not race */ | 896 | /* make sure that we did not race */ |
893 | watch = idr_find(&dev->idr, wd); | 897 | if (likely(idr_find(&dev->idr, wd) == watch)) |
894 | if (likely(watch)) | ||
895 | remove_watch(watch, dev); | 898 | remove_watch(watch, dev); |
896 | 899 | ||
897 | mutex_unlock(&dev->mutex); | 900 | mutex_unlock(&dev->mutex); |