Skip to content
Snippets Groups Projects
Commit 8b99c3cc authored by Lino Sanfilippo's avatar Lino Sanfilippo Committed by Eric Paris
Browse files

inotify: dont skip removal of watch descriptor if creation of ignored event failed


In inotify_ignored_and_remove_idr() the removal of a watch descriptor is skipped
if the allocation of an ignored event failed and we are leaking memory (the
watch descriptor and the mark linked to it).
This patch ensures that the watch descriptor is removed regardless of whether
event creation failed or not.

Signed-off-by: default avatarLino Sanfilippo <LinoSanfilippo@gmx.de>
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent 03a1cec1
No related branches found
No related tags found
No related merge requests found
...@@ -513,13 +513,13 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark, ...@@ -513,13 +513,13 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
struct fsnotify_event_private_data *fsn_event_priv; struct fsnotify_event_private_data *fsn_event_priv;
int ret; int ret;
i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
ignored_event = fsnotify_create_event(NULL, FS_IN_IGNORED, NULL, ignored_event = fsnotify_create_event(NULL, FS_IN_IGNORED, NULL,
FSNOTIFY_EVENT_NONE, NULL, 0, FSNOTIFY_EVENT_NONE, NULL, 0,
GFP_NOFS); GFP_NOFS);
if (!ignored_event) if (!ignored_event)
return; goto skip_send_ignore;
i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
event_priv = kmem_cache_alloc(event_priv_cachep, GFP_NOFS); event_priv = kmem_cache_alloc(event_priv_cachep, GFP_NOFS);
if (unlikely(!event_priv)) if (unlikely(!event_priv))
...@@ -541,9 +541,9 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark, ...@@ -541,9 +541,9 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
} }
skip_send_ignore: skip_send_ignore:
/* matches the reference taken when the event was created */ /* matches the reference taken when the event was created */
fsnotify_put_event(ignored_event); if (ignored_event)
fsnotify_put_event(ignored_event);
/* remove this mark from the idr */ /* remove this mark from the idr */
inotify_remove_from_idr(group, i_mark); inotify_remove_from_idr(group, i_mark);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment