Make this interface consistent with watch and filter key, avoiding the extra string copy and simply consume the new string pointer.
Signed-off-by: Richard Guy Briggs <r...@redhat.com> --- kernel/audit_fsnotify.c | 12 ++---------- kernel/auditfilter.c | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c index c66e91b..c396471 100644 --- a/kernel/audit_fsnotify.c +++ b/kernel/audit_fsnotify.c @@ -94,7 +94,6 @@ struct audit_fsnotify_mark *audit_alloc_mark(char *pathname, int len, struct aud struct dentry *dentry; struct inode *inode; unsigned long ino; - char *local_pathname; dev_t dev; int ret; @@ -115,20 +114,13 @@ struct audit_fsnotify_mark *audit_alloc_mark(char *pathname, int len, struct aud ino = dentry->d_inode->i_ino; } - audit_mark = ERR_PTR(-ENOMEM); - local_pathname = kstrdup(pathname, GFP_KERNEL); - if (!local_pathname) - goto out; - audit_mark = kzalloc(sizeof(*audit_mark), GFP_KERNEL); - if (unlikely(!audit_mark)) { - kfree(local_pathname); + if (unlikely(!audit_mark)) goto out; - } fsnotify_init_mark(&audit_mark->mark, audit_free_fsnotify_mark); audit_mark->mark.mask = AUDIT_FS_EVENTS; - audit_mark->path = local_pathname; + audit_mark->path = pathname; audit_mark->ino = ino; audit_mark->dev = dev; audit_mark->rule = krule; diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index d57c57d..7ffbd7d 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c @@ -561,8 +561,8 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, entry->rule.buflen += f->val; audit_mark = audit_alloc_mark(str, f->val, &entry->rule); - kfree(str); if (IS_ERR(audit_mark)) { + kfree(str); err = PTR_ERR(audit_mark); goto exit_free; } -- 1.7.1 -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit