All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: linux-audit@redhat.com
Cc: Richard Guy Briggs <rgb@redhat.com>
Subject: [PATCH 06/14] audit: avoid double copying the audit_exe path string
Date: Tue, 17 Jun 2014 23:09:41 -0400	[thread overview]
Message-ID: <c1921b8a4f22d90252d4cdee14f455fd35e1d965.1403060033.git.rgb@redhat.com> (raw)
In-Reply-To: <cover.1403060033.git.rgb@redhat.com>
In-Reply-To: <cover.1403060033.git.rgb@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 707df2b..07ebbbb 100644
--- a/kernel/audit_fsnotify.c
+++ b/kernel/audit_fsnotify.c
@@ -99,7 +99,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;
 
@@ -120,20 +119,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 94b6af1..5679b61 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

  parent reply	other threads:[~2014-06-18  3:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18  3:09 [PATCH 00/14] audit by executable name Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 01/14] audit: implement audit by executable Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 02/14] audit: clean simple fsnotify implementation Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 03/14] audit: convert audit_exe to audit_fsnotify Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 04/14] fixup! " Richard Guy Briggs
2014-06-18 13:38   ` Eric Paris
2014-06-18 20:18     ` Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 05/14] fixup! audit: clean simple fsnotify implementation Richard Guy Briggs
2014-06-18  3:09 ` Richard Guy Briggs [this message]
2014-06-18  3:09 ` [PATCH 07/14] fixup! audit: convert audit_exe to audit_fsnotify Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 08/14] fixup! audit: clean simple fsnotify implementation Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 09/14] audit: put rule existence check in canonical order Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 10/14] fixup! audit: implement audit by executable Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 11/14] " Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 12/14] fixup! audit: clean simple fsnotify implementation Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 13/14] audit: continue fleshing out audit by exe Richard Guy Briggs
2014-06-18 14:08   ` Eric Paris
2014-06-25 20:19     ` Richard Guy Briggs
2014-06-18  3:09 ` [PATCH 14/14] audit: enable audit_get/put_mark() Richard Guy Briggs
2014-06-18 14:09   ` Eric Paris
2014-06-18 20:21     ` Richard Guy Briggs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1921b8a4f22d90252d4cdee14f455fd35e1d965.1403060033.git.rgb@redhat.com \
    --to=rgb@redhat.com \
    --cc=linux-audit@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.