On Fri, Jan 6, 2017 at 12:44 PM, Jan Kara <jack@xxxxxxx> wrote: > Currently we initialize mark->group only in fsnotify_add_mark_lock(). > However we will need to access fsnotify_ops of corresponding group from > fsnotify_put_mark() so we need mark->group initialized earlier. Do that > in fsnotify_init_mark() which has a consequence that once > fsnotify_init_mark() is called on a mark, the mark has to be destroyed > by fsnotify_put_mark(). > > Signed-off-by: Jan Kara <jack@xxxxxxx> The API change looks good to me, but as I wrote on v1, I rather that Paul reviews the changes in the audit code, which is the code that was missing the fsnotify_put_mark() calls. > --- a/kernel/audit_fsnotify.c > +++ b/kernel/audit_fsnotify.c > @@ -103,15 +103,16 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa > goto out; > } > > - fsnotify_init_mark(&audit_mark->mark, audit_fsnotify_free_mark); > + fsnotify_init_mark(&audit_mark->mark, audit_fsnotify_group, > + audit_fsnotify_free_mark); > audit_mark->mark.mask = AUDIT_FS_EVENTS; > audit_mark->path = pathname; > audit_update_mark(audit_mark, dentry->d_inode); > audit_mark->rule = krule; > > - ret = fsnotify_add_mark(&audit_mark->mark, audit_fsnotify_group, inode, NULL, true); > + ret = fsnotify_add_mark(&audit_mark->mark, inode, NULL, true); > if (ret < 0) { > - audit_fsnotify_mark_free(audit_mark); > + fsnotify_put_mark(&audit_mark->mark); > audit_mark = ERR_PTR(ret); > } > out: > diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c > index b6785489fd3d..a799cea717de 100644 > --- a/kernel/audit_tree.c > +++ b/kernel/audit_tree.c > @@ -154,7 +154,8 @@ static struct audit_chunk *alloc_chunk(int count) > INIT_LIST_HEAD(&chunk->owners[i].list); > chunk->owners[i].index = i; > } > - fsnotify_init_mark(&chunk->mark, audit_tree_destroy_watch); > + fsnotify_init_mark(&chunk->mark, audit_tree_group, > + audit_tree_destroy_watch); > chunk->mark.mask = FS_IN_IGNORED; > return chunk; > } > @@ -256,7 +257,7 @@ static void untag_chunk(struct node *p) > spin_unlock(&entry->lock); > mutex_unlock(&entry->group->mark_mutex); > if (new) > - free_chunk(new); > + fsnotify_put_mark(&new->mark); > goto out; > } > > @@ -280,8 +281,8 @@ static void untag_chunk(struct node *p) > if (!new) > goto Fallback; > > - if (fsnotify_add_mark_locked(&new->mark, entry->group, > - entry->connector->inode, NULL, 1)) { > + if (fsnotify_add_mark_locked(&new->mark, entry->connector->inode, > + NULL, 1)) { > fsnotify_put_mark(&new->mark); > goto Fallback; > } > @@ -346,7 +347,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree) > return -ENOMEM; > > entry = &chunk->mark; > - if (fsnotify_add_mark(entry, audit_tree_group, inode, NULL, 0)) { > + if (fsnotify_add_mark(entry, inode, NULL, 0)) { > fsnotify_put_mark(entry); > return -ENOSPC; > } > @@ -418,11 +419,11 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) > spin_unlock(&old_entry->lock); > mutex_unlock(&old_entry->group->mark_mutex); > fsnotify_put_mark(old_entry); > - free_chunk(chunk); > + fsnotify_put_mark(&chunk->mark); > return -ENOENT; > } > > - if (fsnotify_add_mark_locked(chunk_entry, old_entry->group, > + if (fsnotify_add_mark_locked(chunk_entry, > old_entry->connector->inode, NULL, 1)) { > spin_unlock(&old_entry->lock); > mutex_unlock(&old_entry->group->mark_mutex); > diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c > index 800084cf0539..0f355086215a 100644 > --- a/kernel/audit_watch.c > +++ b/kernel/audit_watch.c > @@ -157,9 +157,10 @@ static struct audit_parent *audit_init_parent(struct path *path) > > INIT_LIST_HEAD(&parent->watches); > > - fsnotify_init_mark(&parent->mark, audit_watch_free_mark); > + fsnotify_init_mark(&parent->mark, audit_watch_group, > + audit_watch_free_mark); > parent->mark.mask = AUDIT_FS_WATCH; > - ret = fsnotify_add_mark(&parent->mark, audit_watch_group, inode, NULL, 0); > + ret = fsnotify_add_mark(&parent->mark, inode, NULL, 0); > if (ret < 0) { > audit_free_parent(parent); > return ERR_PTR(ret); > -- > 2.10.2 > -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html