[PATCH] fix NULL dereference in inotify_ignore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Don't reassign to watch.  If idr_find() returns NULL, then
put_inotify_watch will choke.

Signed-off-by: Amy Griffis <[email protected]>

diff --git a/fs/inotify.c b/fs/inotify.c
index 7d57253..5d4ba7c 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -889,18 +889,17 @@ static int inotify_ignore(struct inotify
 	get_inotify_watch(watch);
 	inode = watch->inode;
 	mutex_unlock(&dev->mutex);
 
 	mutex_lock(&inode->inotify_mutex);
 	mutex_lock(&dev->mutex);
 
 	/* make sure that we did not race */
-	watch = idr_find(&dev->idr, wd);
-	if (likely(watch))
+	if (likely(idr_find(&dev->idr, wd) == watch))
 		remove_watch(watch, dev);
 
 	mutex_unlock(&dev->mutex);
 	mutex_unlock(&inode->inotify_mutex);
 	put_inotify_watch(watch);
 
 	return 0;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux